File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trivial Question|source:Enthuware| EntityManager injected.

 
Rajeish Mittal
Ranch Hand
Posts: 36
Firefox Browser Hibernate MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kip KapKup
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3669
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajeish Mittal
Ranch Hand
Posts: 36
Firefox Browser Hibernate MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3669
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic