• 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: 239
  • 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
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!