I don't think you can have an inheritance structure like this.  When you
define the parent relationship, the EJB container wants a method
'abstract Category getParent()' which does not exist.

I have a similar tree structure without the inheritance (also called
'Category'), and it works with some caveats.  Watch out for the lack of
support for bidirectional relationships; I only store the parent
relationship and implement the getCategoryChildren() business method
with a call to ((CategoryHome)getEJBHome()).findByParent().  There are
other ways but I found this to be the most pleasant.

Inheritance wasn't really designed into the EJB specification.  You can
use interface inheritance, but otherwise you're asking for pain.

Jeff


>-----Original Message-----
>From: Alex Paransky [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, March 29, 2001 7:32 PM
>To: Orion-Interest
>Subject: Implementation inheritance with ejb...
>
>
>I have a general concept of a TreeNode which could contain a 
>parent (another
>TreeNode) and some children, a Collection of TreeNodes.  So I 
>have defined a
>basic TreeNode such as:
>
>public class TreeNode ... {
>  public void setParent(TreeNode parent) throws RemoteException;
>  public TreeNode getParent() throws RemoteException;
>
>  public void setChildren(Collection children) throws RemoteException;
>  public Collection getChildren() throws RemoteException;
>}
>
>My TreeNodeBean, has the appropriate abstract functions.
>
>Now, I have something called Category, which has a parent/children
>relationship with other categories.  So, when creating a 
>Category, I defined
>it like this:
>
>public interface Category extends TreeNode {
>  public String getName() throws RemoteException;
>  public void setName(String string) throws RemoteException
>}
>
>similary, I defined a CategoryBean as an abstract class which 
>is based on
>TreeNodeBean, with the additional abstract functions to 
>get/set name.  I
>have created a one-to-many relationship between Categories, 
>using parent to
>specify the parent for particular category, and children to 
>indicate the
>children Collection.
>
>When I try to deploy the Category bean, I get the following 
>exception from
>Orion during deployment:
>
>Auto-deploying model (ejb-jar.xml had been touched since the previous
>deployment)... java.lang.NullPointerException
>        at 
>com.evermind.server.ejb.deployment.ContainerManagedField.aep(JAX)
>        at com.evermind.server.ejb.database.fj.afk(JAX)
>        at com.evermind.server.ejb.compilation.gf.ah9(JAX)
>        at com.evermind.server.ejb.compilation.f9.ah9(JAX)
>        at com.evermind.server.ejb.compilation.f9.s7(JAX)
>        at com.evermind.server.ejb.compilation.gf.s7(JAX)
>        at com.evermind.server.ejb.EJBContainer.b_(JAX)
>        at com.evermind.server.Application.b_(JAX)
>        at com.evermind.server.Application.gj(JAX)
>        at com.evermind.server.ApplicationServer.r2(JAX)
>        at com.evermind.server.ApplicationServer.aq0(JAX)
>        at com.evermind.server.ApplicationServer.gj(JAX)
>        at com.evermind.server.hk.run(JAX)
>        at java.lang.Thread.run(Thread.java:484)
>        at com.evermind.util.f.run(JAX)
>
>Is this normal? What does this exception mean?
>
>Thanks.
>-AP_
>
>
>

Reply via email to