Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why zero create() methods in entity bean

 
Shanthi Priya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi raunchers,
A session beans must have atleast one or more create() methods but an entity bean can have zero or more create() methods and atleast one findbyprimarykey(). Why??
 
Eusebio Floriano
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you are not suppose to allow clients to create new entities (create in DB). Don�t forget that create on entity bean is completely diferente from create on session bean.
you�ll probably use finder methods most more frequently than create on entities beans.

Regards
 
Sujatha Kumar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi shanti,

The create method in case of Session Bean is different from Entity Bean.

In case of Session Bean (Both Stateless and Stateful),the call to the
create method results in the creation of a Bean Instance

Where as in entity bean the create method is meant for inserting a row in the database, so one of the Beans will be pulled out from the pool to service the create request.

So unlike in Session Bean bean instances are not created. Unless you are not going to do an insert there is no need of a "create" method in Entity Bean.

Hope it helps.
 
Kshitij Ktambe
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add little more to discussion.

create() method is OPTIONAL for Entity Bean because create() method inserts a new row in database and (let us say that) there might be policy that new entries in the database must be done ONLY through admin tool
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic