Problem modeling parent child relationship

From: Adrian Popa (adrian.pop..pdevel.ro)
Date: Mon Sep 20 2004 - 07:55:45 EDT

  • Next message: Andrus Adamchik: "Re: Problem modeling parent child relationship"

    Hi,

    I am trying to model ,using Cayenne, a parent-child relationship for
    entities stored in the same table. I have a table "content" with 2
    fields: "id" and "parent_id". "id" is the primary key for the table. I
    defined a db relationship from "parent_id" to "id" named "toParent". On
    the content entity I defined a relationship parentContent using the db
    relationship toParent. When I call getParentContent the generated sql
    query displayed in the log is something like that:

    SELECT DISTINCT t0.ID, t0.PARENT_CONTENT_ID FROM CONTENT t0, CONTENT t1
    WHERE t0.ID = t1.PARENT_CONTENT_ID AND ((t0.ID = ?)

    but what I would expect would be:

    SELECT DISTINCT t0.ID, t0.PARENT_CONTENT_ID FROM CONTENT t0, CONTENT t1
    WHERE t0.ID = t1.PARENT_CONTENT_ID AND ((t1.ID = ?)

    Is this a bug or there is a problem with the way I tried to model the
    relationship?

    Best regards,
    Adrian Popa

    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    This e-mail and any files transmitted with it are confidential and
    intended solely for the use of the individual or entity to whom
    they are addressed.
    If you have received this e-mail in error please notify the
    originator of the message. This footer also confirms that this
    e-mail message has been scanned for the presence of computer viruses.

    Any views expressed in this message are those of the individual
    sender, except where the sender specifies and with authority,
    states them to be the views of IPdevel .

    Scanning of this message and addition of this footer is performed
    by SurfControl E-mail Filter software in conjunction with
    virus detection software.



    This archive was generated by hypermail 2.0.0 : Mon Sep 20 2004 - 07:55:30 EDT