On Aug 19, 2008, at 9:12 AM, Kem Elbrader wrote:
> Suppose we have
>
> @Entity
> public class A {
>
> @Id
> private long id;
>
> @ManyToOne
> private A parent;
>
> ... getters and setters
>
> public List<A> path() {
> List<A> path;
> if (parent != null) {
> path = parent.path();
> } else {
> path = new ArrayList<A>();
> }
> path.add(this);
> }
> }
>
> Is it possible to get the list returned by the path method using a
> EJB query?
Not as far as I can see. Some databases allow recursive queries but
this feature is not part of EJBQL.
What you could do is to manage two different sets of bidirectional
relationships, one for the direct parent (one-many and many-one) and
another for all parents in the path (many-many using a join table).
Craig
>
>
> Thanks
Craig L Russell
Architect, Sun Java Enterprise System
http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell_at_sun.com
P.S. A good JDO? O, Gasp!
- application/pkcs7-signature attachment: smime.p7s