I can not figure out how to map the following:

I have a 1-n relationship that I can map just fine. (each Election object has a collection of Ballot objects) This works for me. I can read in the Election objects and their Ballot collections are populated too.

Now I want each Ballot object to have a reference back to it's Election object. So I add a <reference-descriptor> tag to the Ballot section of the repository.xml, referring back to the Election object. Unfortunately, this causes an infinite loop when I try to read in the Elections.

I wonder if anyone could indicate where I've gone wrong.
Thanks, Will


Here are brief versions of the classes and repository.xml:

CLASSES:
class Election {
long id;
Collection ballots
}
class Ballot {
long id;
long electionId;
Election election;
}

REPOSITORY.XML:
<class-descriptor
class="edu.umich.umms.elections.Election"
table="FACELEC_ELECTION"
>
<field-descriptor id="1"
name="id"
column="ELECTION_ID"
jdbc-type="BIGINT"
primarykey="true"
/>
<collection-descriptor
name="ballots"
element-class-ref="edu.umich.umms.elections.Ballot"
>
<inverse-foreignkey field-id-ref="2"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="edu.umich.umms.elections.Ballot"
table="FACELEC_BALLOT"
>
<field-descriptor id="1"
name="id"
column="BALLOT_ID"
jdbc-type="BIGINT"
primarykey="true"
/>
<field-descriptor id="2"
name="electionId"
column="ELECTION_ID"
jdbc-type="BIGINT"
/>
<reference-descriptor
name="election"
class-ref="edu.umich.umms.elections.Election"
>
<foreignkey field-id-ref="2"/>
</reference-descriptor>
</class-descriptor>


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to