aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Trivial Question|source:Enthuware| EntityManager injected. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Trivial Question|source:Enthuware| EntityManager injected." Watch "Trivial Question|source:Enthuware| EntityManager injected." New topic
Author

Trivial Question|source:Enthuware| EntityManager injected.

Rajeish Mittal
Ranch Hand

Joined: May 24, 2012
Posts: 36

Q. What type of EntityManager do you get when Java EE compliant container injects an EntityManager into your component?

I am inclined to think Container managed, transaction scoped Entity Manager. since that is the default
but turns out the answer is Container managed, transaction or extended scoped EntityManager

I don't want to lose mark for silly reason ... when appearing. But wouldn't any person think what would be the default entity manager injected or should he be considering both extended and transaction scoped?

Like i said, it's trivial. but just want to catch the opinion of rest of ranchers.

Thanks


Rajeish Mittal
SCJP 5
Kip KapKup
Greenhorn

Joined: Aug 29, 2012
Posts: 1
I would think so as well.
Even in @Stateful session bean, still need to specify PersistenceContextType.EXTENDED to use extended persistence context.
Martijn van der Salm
Greenhorn

Joined: Aug 30, 2012
Posts: 1
Why don't you email Enthuware about this question? In their mock exams it states that by purchasing their exams you get full service. If you get an answer please post it here aswell.
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3201
    
    2
The right answer is it depends on what kind of entity manager has been requested. But the question does not provide this information. In absence of this information, you cannot assume that it will inject the default one. Therefore, the given answer is correct.
But I agree that the question should be made more clear to avoid this confusion.

HTH,
Paul.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Rajeish Mittal
Ranch Hand

Joined: May 24, 2012
Posts: 36

Paul Anilprem wrote:The right answer is it depends on what kind of entity manager has been requested. But the question does not provide this information. In absence of this information, you cannot assume that it will inject the default one. Therefore, the given answer is correct.
But I agree that the question should be made more clear to avoid this confusion.


Am not able to agree with you on this one. Extended Persistence context is injected in stateful session bean which would be mentioned in the problem statement. In absence of this info, anybody will likely assume stateless session bean. and extended persistence context in stateless component will not make sense. You can inject a transaction scoped container managed persistence context in stateful session bean. and it will still work. nevertheless there will still be problems. but when you say component, the person thinks it is stateless because it is not mentioned it is stateful.

Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3201
    
    2
Rajeish Mittal wrote:
Paul Anilprem wrote:The right answer is it depends on what kind of entity manager has been requested. But the question does not provide this information. In absence of this information, you cannot assume that it will inject the default one. Therefore, the given answer is correct.
But I agree that the question should be made more clear to avoid this confusion.


Am not able to agree with you on this one. Extended Persistence context is injected in stateful session bean which would be mentioned in the problem statement. In absence of this info, anybody will likely assume stateless session bean.

A component can be stateful or stateless. If the question does not specify the type of the bean, why would anyone assume that it is stateless bean? Since the question provides options for both the cases, there is no need to assume anything. That is why the given answer is correct.
Had this option (i.e. Container managed, transaction or extended scoped EntityManager) not been there then the question would have been totally wrong because then it would depend on what you assume and a person may assume anything.

So again, in this case, there is no need for any assumption and the provided options contain one option that does not require any assumption. So that is what you should select.

HTH,
Paul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trivial Question|source:Enthuware| EntityManager injected.
 
Similar Threads
Persitence confusion. Please help.
When is a Persistent Context created ?
Passed SCBCD 5.0 :)
getTransaction() on transaction-scoped persistence context.
EntityManager types in JPA