This week's giveaways are in the JDBC and Relational Databases and A Day in Code forums.
We're giving away four copies each of JDBC Workbook and A Day in Code and have the authors on-line!
See this thread and this one for details.
Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Trivial Question|source:Enthuware| EntityManager injected.

 
Ranch Hand
Posts: 36
Hibernate Firefox Browser MySQL Database
  • 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
 
Greenhorn
Posts: 1
  • 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.
 
Greenhorn
Posts: 1
  • 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.
 
Enthuware Software Support
Posts: 4427
41
  • 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
Hibernate Firefox Browser MySQL Database
  • 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
Posts: 4427
41
  • 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.
 
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic