• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The root of a persistence unit

 
Tang Yue
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Chaminda Amarasinghe
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell me the exam no and and question no?
 
Kristel Nieuwenhuys
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3713
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic