• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Query about PersistenceContext Annotation Attribute unitName

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Devaka Cooray
Marshal
Pie
Posts: 4879
402
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic