This week's book giveaway is in the Python forum.
We're giving away four copies of High Performance Python for Data Analytics and have Tiago Rodrigues Antao on-line!
See this thread for details.
Win a copy of High Performance Python for Data Analytics this week in the Python 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Inheritance & entity beans

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still not clear about inheritance in entity beans,if its possible
then what are the issues to consider .
Types of inheritance we implement.
can any one give me a simple example.

thanx
V
 
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,
Your entity bean is free to implement another Java class. EJB supports inheritance just as Java does, but EJB does *not* (at this time) support what they call "bean inheritance". Bean inheritance would give you the capability to inherit not just the things you'd inherit through the Java language, but also some of the 'beanness'. If you're familiar with non-enterprise Javabeans, they DO support bean inheritance (through things like BeanInfo). But EJB does not.
So, you can go ahead and have your bean inherit from another class. In EJB 1.1, it was not uncommon to subclass a bean-managed entity bean and make it container-managed, which is why the ejbCreate() method of a CMP bean has the same return type (the pk) even though the Container does not want or need you to return the PK from a CMP bean, and you are only supposed to return 'null' from a CMP bean.
If some form of bean inheritance were possible, it might mean, for example, that the deployment descriptor of the superclass bean would be picked up when you deploy the subclass bean, and then you might create only a *partial* DD for the subclass bean, perhaps putting in ONLY the parts of the DD that you want to be different from the superclass bean's behavior. There would be an awful lot of issues and complexities to work out, but bean inheritance might be really cool... but it's not supported now (and I don't believe in 2.1, either).
cheers,
Kathy
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A simple example;
Inheritance within bean class implementations and component interfaces allow you to build a certain amount of layering into a design,just as we would if we were't using EJBs.Typically , stop subclassing when you reach the first concrete entity bean along a branch in the inheritance tree.The first step in this approach is create an abstract implementation of EntityBean for example

public abstract class AbstractEntity implements EntityBean{

protected EntityContext ctx;
public void ejbActivate(){}
public void ejbLoad(){}
public void ejbPassivate(){}
public void ejbRemove() throws RE{}
public void ejbStore(){ }
public void setEntityContext(EntityContext newCtx){
ctx=newCtx;
}
public void unsetEntityContext(){
ctx=null;
}
}
This class does little more than manage the assignment of the EntityContext,but even that reduces what you have to implement in a concrete
entity class.if our design called for any other behaviour common to all entity beans,this class would provide a place to implement that.

(concrete entity bean)
public class MyEntityBean extends AbstractEntity implements EntityBean{
/*
No implementation for EntityBean interface methods required here(you can always override them.)
*/
}
It isn't neccessary for this class to implement EntityBean, but some development tools don't reconize a class as an enterprise bean if it doesn't explicitly say "implements" the corresponding interface.
[ November 26, 2003: Message edited by: Amer Khan ]
 
vikram goyal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
V
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Weblogic 8.1 workshops also uses inheritance. If you try to create a stateless session thru the wizard, it inherits from a standard class "GenericSessionBean" or something like that. This beans has the lifecycle/callback methods and also some System.out.println methods.
The session bean class that you implement has only your business methods.
I guess this feature of weblogic workshop is for more code clarity.
 
rubbery bacon. rubbery tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic