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

ejbCreate() method for EntityBean

 
s khosa
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • 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
 
arvindh seshadri
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best practice is to have create() method in the bean .
 
Required Field
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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 .
 
Raghubir Bose
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • 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.
 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic