cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

adrian_goerler
Active Participant
0 Kudos

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