• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Valid ejbCreate method?

 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this leagl declaration for CMP beans ejbCreate method --

public int ejbCreate() throws javax.ejb.CreateException
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is. It is even valid (ie throwing CreateException) for Session Beans but not for MDBs.
[ March 31, 2005: Message edited by: Keerthi P ]
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

This is one from cofee cram in HFEJB
page 363. Enitity bean synchonization chapter.
Question 5.
They have marked this as invalid....
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops. I did not notice the return type of this method. It can't be primitive.
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also the ejbCreate method parameters are missing.
[ March 31, 2005: Message edited by: Ravindra Janapareddy ]
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I agree primitive return type is not valid.
SO the method is invalid.

But as I understand, create parameteres are NOT MUST a s per spec. ALthough logically it does not make much sense having create method without any parameters in ENtity bean.

SO I dont agree with Ravindra's poitn for saying this method is invalid.

Am I right?

Gemini
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ejbSpecs]
SessionBean
The method arguments must be legal types for RMI/IIOP if there is a create<METHOD> corresponding to the ejbCreate<METHOD> method on the session bean�s remote home interface.

A stateless session bean must define a single ejbCreate method, with no arguments.EntityBean
public PrimaryKeyClass ejbCreate<METHOD>(...);

If the ejbCreate<METHOD> method corresponds to a create<METHOD> on the entity bean�s remote home interface, the method arguments and return value types must be legal types for RMI-IIOP.

Specs specifically mentions stateless session bean must/can have ejbCreate with no arguments but it doesn't say anything about stateful session bean or entity bean and if specs leave it open for the developer to draw conclusion then it doesn't mean that it is valid to have a ejbCreate with no arguments in it in a stateful or entity bean.

Thanks

-- Ravi
[ March 31, 2005: Message edited by: Ravindra Janapareddy ]
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SO I dont agree with Ravindra's poitn for saying this method is invalid.

Am I right?


Yep. You may still have no-arg create() and a corresponding ejbCreate() in the bean class. The container wouldn't be bothering.
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Keerthi is right. It doesn't make any sense to have a create method without any parameters but the specs don't say anything about this . That means we can have a create method with no arguments . But it will be like telling the container to create somehting and the something is nothing.

Sawan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic