This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

InventoryManagement declaration?  RSS feed

 
Ranch Hand
Posts: 223
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,


16.11.2Application Assembler’s Responsibilities
The Application Assembler can use the persistence-unit-name element in the deployment descriptor to specify a reference to a persistence unit using the syntax described in section 16.10.2. In this manner, multiple persistence units with the same persistence unit name may be uniquely identified when persistence unit names cannot be changed.
For example,
...
<enterprise-beans>
<session>
...
<ejb-name>InventoryManagerBean</ejb-name>
<ejb-class>
com.wombat.empl.InventoryManagerBean
</ejb-class>
...
<persistence-context-ref>
<description>
Persistence context for the inventory management
application.
</description>
<persistence-context-ref-name>
persistence/InventoryAppMgr
</persistence-context-ref-name>
<persistence-unit-name>
../lib/inventory.jar#InventoryManagement
</persistence-unit-name>
</persistence-context-ref>
...
</session>
</enterprise-beans>
...
The Application Assembler uses the persistence-unit-name element to link the persistence unit name InventoryManagement declared in the InventoryManagerBean to the persistence unit named InventoryManagement defined in inventory.jar.



Where is (and/or how does) the persistence unit name InventoryManagement declared in the InventoryManagerBean (look)?
 
Creator of Enthuware JWS+ V6
Bartender
Posts: 3121
259
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Where is (and/or how does) the persistence unit name InventoryManagement declared in the InventoryManagerBean (look)?


That would be in the persistence.xml located in META-INF directory of the inventory.jar file. (assuming it is a standard ejb-jar file)
 
Charles O'Leary
Ranch Hand
Posts: 223
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frits.



InventoryManagement would appear declared as in the above first? Secondly, application assemblers can then use the deployment descriptor persistence-unit-name element (quoted in my initial question) to refer or link to the persistence unit specified in the persistence.xml located in META-INF directory of the inventory.jar file?

Both, in this case the bean-based and the persistence.xml-based, declarations along with the deployment descriptor persistence-unit-name element, which ties these together, are required for the link? Correct?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender
Posts: 3121
259
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is exactly how I understood it as well.

You would only need this if you have two persistence units with the same name in your application. This way you don't have to change your code, but only link the unit-names to different locations.
 
Charles O'Leary
Ranch Hand
Posts: 223
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frits.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!