-
1. Re: CMR with relationship to the same EJB object.
dward2 Aug 22, 2002 4:51 PM (in response to eric138)Yes; I do it. Don't think of it as parent->children. Think of it as child->parent, unidirectional. That way, it's easy to look upward to get the parent. Now, to get the children, using an ejb-ql finder that finds all children with a parent of the id.
For example:
public abstract class TreeNodeBean implements EntityBean {
public abstract void setParent(TreeNodeLocal t);
public abstract TreeNodeLocal getParent();
}
public interface TreeNodeLocaleHome extends EJBLocalHome {
public Collection findChildrenOfParent(Integer parentKey);
}
<query-method>
<method-name>findChildrenOfParent</method-name>
<method-params>
<method-param>java.lang.Integer</method-param>
</method-params>
</query-method>
<ebj-ql>SELECT OBJECT(t) FROM TreeNode t WHERE t.parent.key = ?1</ejb-ql>