• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

when is an instance of a entity bean created??

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. before ejbCreate()
2. after ejbCreate()
3. after ejbPostCreate()
4.within ejbCreate()

Thank You.
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its created before ejbCreate().
First from the "does not exist" state the newInstance() is called which calls your Entity beans default constructor,
2) then its setEntityContext()(if needed)
3) then home and finder methods
4) then ejbCreate()
Look at the Entity bean life cycle, you should find all this there
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The entity bean instance is *created* whenever the Container decides to make beans for the pool, but of course this is *always* before any Container callback methods are invoked. Just don't forget that ejbCreate() has NOTHING to do with entity bean *instance* creation.
So, a bean's first real *business method* might be ejbCreate() (invoked when the client calls create()), and that could happen before any other home or component interface methods.
If you're asking this for the exam, just be sure to keep the difference between *bean / entity* creation and bean *instance* creation. The bean/entity is created when the client calls create(). But the bean *instance* is created (which really means *instantiated* and given an entity context) when the Container chooses. A single bean instance might be associated with many, many entity bean creations. In other words, a single bean instance, once instantiated/created and placed into the pool, might come out of the pool over and over again to *create* new entity beans.
The real confusion is over the term *bean* vs. *instance*. (And the spec is sometimes a little loose with that.) A *bean* is a *realization of a real entity from the underlying persistent store*. That's why we can say that an entity *bean* survives a Container crash, even though the entity bean *instance* obviously does not survive. As long as it is still possible for an entity bean instance to be populated with a particular entity's data, that *bean* is said to exist.
We have the same issue with destruction that we have with creation... the *bean* can be deleted even though the bean *instance* just goes back to the pool. The *bean* deletion/removal is NOT tied to the bean *instance* removal. Bean removal is tied to the client calling remove() on that bean (or through a cascading delete set-up for a CMR relationship), but the bean *instance* removal is, once again, completely up to the Container's decision to remove a bean from the pool (by calling unsetEntityContext()) or because of a crash or because the bean throws a system exception.
cheers,
Kathy
p.s. if you haven't checked out the OO forum today... there's a promotion going on for "Dating Design Patterns". Yes, you read that right. Author Solveig Haugland has the inside gossip and details about what the Gang of Four were *really* doing...
(have fun)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic