Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

why zero create() methods in entity bean

 
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??
 
Ranch Hand
Posts: 241
  • 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
 
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.
 
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!