File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Persistence Contexts, Entity Managers - 3 queries !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Persistence Contexts, Entity Managers - 3 queries !!" Watch "Persistence Contexts, Entity Managers - 3 queries !!" New topic

Persistence Contexts, Entity Managers - 3 queries !!

Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Query 1 -
There are two ways to obtain Persistence Contexts �
1.using the annotations/the persistence XML
2.using the Entity-Manager-Factory API

O�Reilly�s Book explains both, but in the end says 1. is easier than 2 and that since Method 2 is error prone, developers should try to make use of the easy facilities provided be the EJB container. My question is, does the exam expects us to remember each of them in depth?

Query 2 -
Also, across chapter 5, the book talks of the Java SE and even the Java EE environment. I did not understand what the Java SE has to do when we are learning something very specific to enterprise apps. But after some thought I came to know that the persistence API to tightly integrated with EJB (a Java EE technology) it can also be very well used by Java SE programs. So, such programs can also use this api to persist things into the database. Am I correct? And since this is possible, there are two ways in which you can configure the persistence.xml tags like
<jar-file>, <jta-data-source>, <provider>. One for the Java EE environment and the other for the Java SE environment. Should one worry about the Java SE for the exam ?

Query 3 -
Again, there are two ways to obtain Entity-Manager factory � one using the SE way the Entity-Manager-Factory API) and the other using the EE. Should one know both the ways? Also in both the ways there are method where, the book talk of passing a map, which corresponds to the <properties> tag of the persistence.xml file. How are the properties passed to the method? Does the developer write code to pass these? How are the properties mapped to the map? Is the mapping like �

Property name = map key
Property value = key�s value
I think there are dedicated chapters to explain stuff, but I still had some initial questions.

Please forgive me for posting many questions in a single post. I was really deciphering the new technology called EJB3.0. I think this is a lot of food for thought for the masters like Narendra and others.

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 951

I am not master in technology. I am just studying new technologies like you. I also facing lot of problems like you. Always, we have to learn from mistakes.

Using annotations/Deployment descriptor is easy because it save lot of coding.
I do not thing that the factory API are error prone. This is only way to get entity managers in SE environment as these are not managed objects and the annotations are not supported.

The exam topics are about the JPA not the java EE. So you have to learn how you can use the JPA in SE environment also.

You have to know the elements in persistence.xml and orm.xml at introductory level.No deep level knowledge is required. But these topics are interesting to study.

The <properties> element is specific to persistence manager. Yo should know only for what purpose the element is used. The understanding property names and values are not required for the exam.


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Thanks for the input Narendra. So to conclude -

Query 2 - Yes you should know about the Java SE ways too for the JPA

Query 3 : The oreilly book keeps on saying this -

The <properties> element defines the set of vendor-specific attributes passed to the persistence provider. They specify configuration that is specific to a vendor implementation.

This is too short to make some sense. I am just in chapter 5 and i think some good explanation will come in the coming chapters. But please tell me more for the time being.

Query 1 - The error prone thing is said on O Reilly page 86. What all section 5.4.2 talks of is also important for exam.

Any comments?
[ February 04, 2008: Message edited by: Niranjan Deshpande ]
I agree. Here's the link:
subject: Persistence Contexts, Entity Managers - 3 queries !!
It's not a secret anymore!