GeeCON Prague 2014*
The moose likes JPA Certification (OCEJPA) and the fly likes What we need in order to use @PersistenceContext? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » JPA Certification (OCEJPA)
Bookmark "What we need in order to use @PersistenceContext?" Watch "What we need in order to use @PersistenceContext?" New topic
Author

What we need in order to use @PersistenceContext?

Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 187
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

Joined: Aug 05, 2011
Posts: 115

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.


With Regards :-
Harmeet Singh
Singh Harmeet
Ranch Hand

Joined: Aug 05, 2011
Posts: 115

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.
 
GeeCON Prague 2014
 
subject: What we need in order to use @PersistenceContext?