Forums Register Login

A Query about PersistenceContext Annotation Attribute unitName

+Pie Number of slices to send: Send
Hi ,

I saw number of examples in which inside StatelessBean @PersistenceContext is used

For example :

This is inside a @Stateless Session Bean .

@PersistenceContext(unitName="myPersistenceUnit")
@Stateless
public class InventoryManagerBean implements InventoryManager
{
---
--
}

Please let me know what does unitName indicates here ??
Please throw a little light
+Pie Number of slices to send: Send
As stated in the specification:

The name of the persistence unit. If the unitName element is specified, the persistence unit for the entity manager that is accessible in JNDI must have the same name

 
+Pie Number of slices to send: Send
Thank you .
I don't want to use persistence.xml file . Can we do this with the help of @PersistenceContext Annotation and passing unitName into it .


Please tell me whether this is possible ??
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1442 times.
Similar Threads
What is unitName in @PersistenceContext?
Obtaining a PersistenceContext in Java EE
EJB with Hibernate
JNDI Lookup code for EntityMananger inside SessionBean
Difference between usage of PersistenceContext and PersistenceUnit ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:25:48.