Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What we need in order to use @PersistenceContext?

 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day,

I'm have limited knowledge in JPA, and would appreciated if someone can share me the understanding of how we can use @PersistenceContext, what are the file required to in place?
for instance : Persistence.xml ?

I tried google and can't get a good sample to Help my understanding, I did having a tried but the entity manager always null

P/S: using hibernate, JPA, Spring

Thanks a millions!
 
Singh Harmeet
Ranch Hand
Posts: 115
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the JPA the persistence context and persistence unit have one to one relation(this is not rdbms relation) . the persistence context is used to manipulate the entities operations and persist the entities who are available in persistence context . the @PersistenceContext annotation is mostly used with JavaEE container , in which the persistence context is automatically managed by container. persistence context need the reference of persistence unit , because in the persistence unit we mention all the entities and transaction type etc . @PersistenceContext have unitName attribute to take the reference of persistence unit.
 
Singh Harmeet
Ranch Hand
Posts: 115
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Singh Harmeet wrote:in JPA the persistence context and persistence unit have one to one relation(this is not rdbms relation) . the persistence context is used to manipulate the entities operations and persist the entities who are available in persistence context . the @PersistenceContext annotation is mostly used with JavaEE container , in which the persistence context is automatically managed by container. persistence context need the reference of persistence unit , because in the persistence unit we mention all the entities and transaction type etc . @PersistenceContext have unitName attribute to take the reference of persistence unit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic