Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using inheritance with EJB  RSS feed

 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gurus,
Can I inherit an EJB from a "simple" java class.
If yes, what are the concern to be aware of.
Thanks
 
Kirt Henrie
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I always extend a detail object in my entity beans. The detail object serves as my serializable object to return to the client. It saves me the added effort of adding variables, getters and setters in both classes (defined in the detail object).
The only real problem I have seen with this is that you need to give the variables in the detail object broader scope. The specification mandates public scope for CMP, but you can use package or protected on BMP (depending on package structure).
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the majority (maybe all) of the samples I've read in books, a EJB object never extends a java class. I can't see any explanation of that choice.
Nevertheless, the EJB 2.0 spec allows inheritance
xImplementation class inheritance. It is possible to take advantage of the Java class implementation inheritance mechanism for the enterprise bean class. For example, the class Checkin-gAccountBean class can extend the AccountBean class to inherit the implementation of
the business methods

Is it better not to use class inheritance in the "real world" ?? Why ?
 
syed mraza
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks
i need a bit help here (since u r already using inheritence in EJB) i have extended a (session) EJB from another (session)EJB. both have compiled and deployed perfectly fine. BUT whn i look up the 'Child' bean i get "Unable to resolve 'Child'".... though parent bean is looked up perfectly fine. (i dont *think* i;m doing anything wrong but still....)
any suggestions, thoughts???
thnx
ciao
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!