Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

ejbCreate

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a cmp bean, ejbCreate( ) inserts a row into the database. How do we code the ejbCreate() method if all we want is to query the database and make no insertions or deletions.
How would ejbCreate( abcPK ){
}
suit in this scenario ( abcPk is the primary key ).
2) Could we have multiple ejbCreate methods ?
3) What happens if there is no ejbCreate method in the bean. ( i guess it will fail the verify ejb test )

Any clues anyone ?
Thanks

[ May 14, 2003: Message edited by: bobby chaurasia ]
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EJB spec, 10.6.4 says "The entity bean class may define zero or more ejbCreate<METHOD>(...) methods"
It is quite possible to have read only entity beans that read existing data from a database. In that case there will be no ejbCreate methods.
You can have as many ejbCreate methods as you like, which is similar to having multiple constructors. The primary key would still be the same though.
I would be interested to hear of anyone actually using an entity bean without an ejbCreate method.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think one should not use any sql in CMP entity beans. If required you should use BMP.
Thanks,
Anup
 
bobby chaurasia
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave,
I tend to agree with you. This was my gut feel as well but I just wanted to have a second opinion. Yes I would also like to hear from someone who has used beans without the create method.
Cheers
 
Dave Cronin
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thinking of a possible scenario, you could have a situation where you import data from another application which have already defined primary keys for the entities. Then you could probably use CMP entity beans just to query the database. I am not so sure about how to prevent deletions - maybe you could throw an exception if any tries to call remove().
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic