Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

why zero create() methods in entity bean

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic