Skip to Content
author's profile photo Former Member
Former Member

JDO Mapping to same object as parent/child 1:n relationship

Hello,

i'm trying to do a mapping the following way:

Node (1:n) Node where the Node should have the following

accessors:

getChildNodes() : Set

getParentalNode() : Node

I do have the getChildNodes mapping working, but cannot get the parental relation established due to problems with the Node.map file containing the following:

<relationship-field name="parentalNode" multiplicity="one">

<foreign-key name="NODE_TO_PARENTALNODE"

foreign-key-table="TPB_NODE"

primary-key-table="TPB_NODE">

<column-pair foreign-key-column="ID"

primary-key-column="PARENT_ID"/>

</foreign-key>

</relationship-field>

Using this the checker complains about

javax.jdo.JDOFatalUserException: Error in mapping model of class Node: Relationship of field parentalNode: Primary key column PARENT_ID of relationship's foreign key and target class's com.vw.tpb.node.model.Node primary key columns do not match.

Well. When i do a 1:n relation to myself how should i create two primary keys then ?

Anybody some ideas on this one ?

regards, Udo

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Posted on Jul 06, 2004 at 10:50 AM

    Hi Udo,

    for the reference from child to parent, the column "ID" should be the primary key colum, whereas the column "PARENT_ID" should be the foreign key column.

    Best regards,

    Adrian

    Add comment
    10|10000 characters needed characters exceeded