my dog learned polymorphism*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Obtaining a PersistenceContext in Java EE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Obtaining a PersistenceContext in Java EE" Watch "Obtaining a PersistenceContext in Java EE" New topic
Author

Obtaining a PersistenceContext in Java EE

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9351
    
    2

Guys,

What is the deal with obtaining a PersistenceContext using @PersistencContext annotation and what difference or a performance overhead it is when I say the following,




SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
the first one is managed by the application and the second one by container.

So you can conclude the container managed persistence context is more efficient in it's operation's.


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9351
    
    2

But even in the line,



it is the contaner that performs the DI. So dosn't that mean that it is managed by the container?
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
In this case the entity manager factory is managed by the container, but not the entity manager itself.

As a remark concerning performance aspects: I was once told on glassfish forum that creating an entity manager is a lightweight operation.


SCJP 5 (98%) - SCBCD 5 (98%)
 
Consider Paul's rocket mass heater.
 
subject: Obtaining a PersistenceContext in Java EE