• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

ejbCreate() method for EntityBean

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Does Entity bean need to define atleast one ejbCreate() method? I am confused because as per EdRoman's book we need not define any ejbCreate() method if we do not want client's to create data in the database.

Thanks
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only findByPrimaryKey() is mandatory for entity beans. create() is optional. For session beans, create() is mandatory and for every create () in the home interface, you need to have a matching ejbCreate() in the bean class
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best practice is to have create() method in the bean .
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And why is it a 'best practice'?

If I don't have an create/ejbCreate method in an entity bean, that only means that no new records can be created thru my bean. Which IMHO, is a reasonable requirement.

Calling it a 'best practice' just sounds odd to me. Is it because there is always a remove() method - on all EJBs (due to EJBHome/EJBObject). There is no way to not have a remove/ejbRemove method on my EJB!

Originally posted by arvindh seshadri:
The best practice is to have create() method in the bean .

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As per EJB1.1 Specification ejbCreate for entity beans is optional.This is possibly due to the reason that several vendors like BEA supports automatic primary key generation feature for CMP entity beans.Since in EJB1.1 the ejbCreate returns the primary key class, this might hamper their internal implementation of ejbCreate which is essentially a container callback.
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Best practice is like 'brushing your teeth'. You don't have to do it, but it improves your breath and life time of the teeth.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic