-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to map an associative table?
PostPosted: Wed May 05, 2004 11:34 pm 
Newbie

Joined: Wed May 05, 2004 10:08 pm
Posts: 1
Location: Sydney
Hi,
I am new to hibernate. My problem is I am trying to do a basic map for an associative table. I have three tables:
1) SR_IDENTITIES table with pk of IDENTITY_ID,VERSION_ID
2) SR_LOANS table with pk of LOAN_ID,VERSION_ID
3) SR_LOAN_CUSTOMERS table with a
pk of LOAN_ID,IDENTITY_ID,VERSION_ID
fk (LOAN_ID,VERSION_ID) references SR_LOANS(LOAN_ID,VERSION_ID)
fk (IDENTITY_ID,VERSION_ID) references SR_IDENTITIES(IDENTITY_ID,VERSION_ID)

I get this error:
net.sf.hibernate.MappingException: Repeated column in mapping for collection: com.afl.domain.model.party.Person.loanCustomers column: VERSION_ID
at net.sf.hibernate.collection.AbstractCollectionPersister.checkColumnDuplication(AbstractCollectionPersister.java:666)
at net.sf.hibernate.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:163)
at net.sf.hibernate.collection.BasicCollectionPersister.<init>(BasicCollectionPersister.java:35)
at net.sf.hibernate.persister.PersisterFactory.createCollectionPersister(PersisterFactory.java:54)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:148)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:750)
at com.afl.common.HibernateConnectionUtil.<clinit>(HibernateConnectionUtil.java:30)
at com.afl.domain.dao.party.PartyDAOTest.doSetUp(PartyDAOTest.java:87)
at com.afl.domain.dao.party.PartyDAOTest.setUp(PartyDAOTest.java:73)


Here is a copy of my mapping documents:
A)
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class
name="com.afl.domain.model.party.Person"
table="SR_IDENTITIES"
dynamic-update="false"
>

<composite-id name="compositeKey" class="com.afl.common.CompositeKey" unsaved-value="any">
<key-property name = "key1" column="IDENTITY_ID"/>
<key-property name = "key2" column="VERSION_ID"/>
</composite-id>

<property
name="typeCd"
update="true"
insert="true"
column="TYPE_CD"
type="string"
/>

<property
name="customerKey"
update="true"
insert="true"
column="CUSTOMER_KEY"
type="string"
/>

<property
name="maritalStatus"
update="true"
insert="true"
column="MARITAL_CD"
type="string"
/>

<set name="loanCustomers"
table="SR_LOAN_CUSTOMERS"
lazy="false"
inverse="true"
cascade="all"
sort="unsorted"
>
<key>
<column name="IDENTITY_ID"/>
<column name="VERSION_ID"/>
</key>

<composite-element class="com.afl.domain.model.party.LoanCustomer">


<property
name="workingVersionChangedCd"
update="true"
insert="true"
column="WORKING_VERSION_CHANGED_CD"
type="string"
/>
<property
name="lastUpdateOperatorId"
update="true"
insert="true"
column="LAST_UPD_OPERATOR_TXT"
type="string"
/>



<many-to-one name="loans"
class="com.afl.domain.model.loan.Loan">
<column name="LOAN_ID" />
<column name="VERSION_ID"/>
</many-to-one>


</composite-element>

</set>


</class>

</hibernate-mapping>

B (Loans mapping file)

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class
name="afl.domain.model.loan.Loan"
table="SR_LOANS"
dynamic-update="false"
>

<composite-id name="compositeKey" class="afl.common.CompositeKey" unsaved-value="any">
<key-property name = "key1" column="LOAN_ID"/>
<key-property name = "key2" column="VERSION_ID"/>

</composite-id>

<property
name="loanTypeCd"
update="true"
insert="true"
column="LOAN_TYPE_CD"
type="string"
/>



</class>

</hibernate-mapping>

Any help appreciated.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.