Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Question from SUN's ejb quiz

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
8. At what point, precisely, in the life-cycle is a container-managed entity bean considered created?
A. Immediately prior to the execution of its ejbCreate() method
B. Immediately after the execution of its ejbCreate() method
C. After the CMP bean's data has been committed to the underlying persistent datastore
D. During the execution of its ejbPostCreate() method
Answer provided: B
However my answer is C. Let's assumpt that we have a transaction which create two entity beans:
1)transcation start
2)create EntityA -- call ejbCreate() of EntityA
3)create EntityB -- call ejbCreate() of EntityB
4)commit or rollback
after step 2) -- calling ejbCreate() of EntityA sucessfully, we may have error while calling ejbCreate() of EntityB, then the container would rollback the creation of EntityA. So from this point of view, the provided answer B is incorrect.
Welcome comments,
Tom
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To restate the question:
At what point, precisely, in the life-cycle is a container-managed entity bean considered created?
I would agree with Sun's answer that the bean is "created" immediately after the execution of its ejbCreate() method. Bean creation and transaction isolation are two separate issues. Even if the container has not committed the bean to the datastore, it is still considered "created" because you have a new instance of a Primary Key object for that entity.
Synchonization of the EJB and the database is the container's responsibility. Given your assumptions I would answer yes to the interjected question.

1)transcation start
2)create EntityA -- call ejbCreate() of EntityA
2a) Do I have a "created" bean?
3)create EntityB -- call ejbCreate() of EntityB
3a) exception, ejbCreate never finished (no bean created)
4)commit or rollback
Comments?
[ January 07, 2003: Message edited by: Jack Coleman ]
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic