• Post Reply Bookmark Topic Watch Topic
  • New Topic

EM and Persistence Contexts

 
Mohammad Jaber
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Does Each EntityManager have only one PersistenceContext , and does that requires only transaction per PersistenceContext !???

Thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes there is only one persistence context in an EntityManager or Session object. it is a has a relationship.

Mark
 
Antero Laukkanen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
..and as long as the entity managers come from the same factory, the persistence context is the same..?
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Antero Laukkanen:
..and as long as the entity managers come from the same factory, the persistence context is the same..?

They will only be the same if the entity managers are both container-managed and were obtained in the same transaction.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!