• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

create meothd overload ?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A home interface defines one or more create<METHOD>(...) methods, one for each way to create a session object.
Is each create need unique name, do not allow overload? such as create(String id), create(String id, int i)).
 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Bin:
I'm pretty sure that you can overload create method as long as the parameter lists are different. Just make sure that for each create<method> method in your home you have a corresponding ejbCreate<method> in your bean class.
Hope this helps.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bin,
Welcome to JavaRanch and this forum !
I agree with what Keith wrote above, as far as we talk about *stateful* session beans and/or entity beans, meaning that such an overloading is N/A to stateless session beans.
Best,
Phil.
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy -- Keith and Phillipe are correct: you can overload create methods ONLY for stateful session beans and entity beans.
Also, you can make different create *names* by appending something after the "create" part of the method name, like createBigAccount(), createFoo(), etc. But you don't have to. You're free to overload create methods as long as you follow Java standard rules for method overloading (i.e. must vary the argument list) and you do as Keith said, match each create with ejbCreate() in the bean (and for an entity, ejbPostCreate() as well).
FYI -- someone has brought it to my attention that there is a bug in the RI that causes the verifier to complain if you do NOT have a create defined for an entity bean. So please remember that the exam is based on the specification, and where the RI differs from the spec, you MUST follow the spec. So it's perfectly valid in the spec to define an entity bean with NO create() method, but the RI verifier will complain. That's just an RI bug. Oh, and the RI also forces you (you've probably discovered this) to define a CreateException on create methods in your bean class. It is always considered good practice, but not required in the spec. But the RI will FORCE you to declare it in your bean. Just be aware of those little *fun* issues
cheers,
Kathy
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kathy,

Oh, and the RI also forces you (you've probably discovered this) to define a CreateException on create methods in your bean class. It is always considered good practice, but not required in the spec.


Except for entity beans !
Here is what I remembered about javax.ejb.CreateException :

Best,
Phil.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic