• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on EJB

 
Apratim Khandalkar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,
Whole solving one question come is
Is it compulsory for Enitity and Session bean to have atleast one create method???
I think this is not complusory becase entity bean can choose not to write any create method ??

Please share your views
Thanks
Apratim
 
Ricardo Ferreira
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Apratim Khandalkar:
Hi All ,
Whole solving one question come is
Is it compulsory for Enitity and Session bean to have atleast one create method???
I think this is not complusory becase entity bean can choose not to write any create method ??

Please share your views
Thanks
Apratim


Hi Apratim,

In Fact, session and entity beans must have at least on create method in yours home interface. But in the case of entity beans, they can to choose to not have an create method, because they can be achieved by finder methods. Remember that, entity beans represents an row of an relational database. So, those records can be accessed using finders methods.

If an bean provider choose to not create an create method for an entity bean, it is because this bean will be for read-only pourpouses only. Something like the fast lane reader pattern does. Makes available tabular data to the application.

But, the session beans must have at least one create method, because it is the only way to access the bean (that represents a service for the application). Remember that the home interface acts as a factory for the enterprise beans. So, to access the bean, you should use the factory home interface, calling the create method related.

That is, the reason because session beans must have on create method declared in your home interface, and entity beans can choose to not define an create method.

I hope have helped you!~
 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend the EJB specificaion on this. It clearly states when you need create method on Entity and Session beans.
 
Apratim Khandalkar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot Ricardo,
This was very good explanation.It helpe me lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic