• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Question from SUN's ejb quiz

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic