File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes The root of a persistence unit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "The root of a persistence unit" Watch "The root of a persistence unit" New topic
Author

The root of a persistence unit

Tang Yue
Ranch Hand

Joined: Nov 11, 2008
Posts: 40
In Enthuware, there is a question:
"
A persistence archive file named ejbplusPU.jar contains the following files:

com/enthu/ejbplus/Account.class
com/enthu/ejbplus/Person.class
META-INF/persistence.xml
META-INF/orm.xml

Given that Account and Person classes contain all the mapping information in the form of annotations, which of the above files will always be examined by the container when this jar is deployed? "

My answer is "persistence.xml" and "orm.xml", but no class files.

But the correct answer includes those class files.

According to persistence spec, "Any annotated managed
persistence classes found in the root of the persistence unit are added to the list of managed persistence classes."

Here, Account.class and Person.class aren't at the root of the persistence unit, so why should they be examined?


Houston Rockets go go go!
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Can you tell me the exam no and and question no?
Kristel Nieuwenhuys
Greenhorn

Joined: Nov 21, 2008
Posts: 1
The JPA spec states the following:

"The jar file or directory whose META-INF directory contains the persistence.xml file is termed the root of the persistence unit."

As your Account and Person class are part of this jar file, they are seen as "annotated managed persistence classes found in the root of the persistence unit".
[ November 21, 2008: Message edited by: Kristel Nieuwenhuys ]
Tang Yue
Ranch Hand

Joined: Nov 11, 2008
Posts: 40
Hello,Kristel
You mean, any class file found in the root of the persistence unit, or the subdirectories of the root of the persistene unit is evaluated?
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3335
    
    8
Thanks for pointing it out. The question should make it clear that Account and Person class belong to com.enthu.ejbplus package, in which case, they are positioned correctly in the jar file and will be inspected by the container for annotations.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The root of a persistence unit