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.  [ 2 posts ] 
Author Message
 Post subject: DynamicMode MAP - Link table
PostPosted: Fri Sep 14, 2007 7:31 am 
Newbie

Joined: Fri Sep 14, 2007 7:18 am
Posts: 2
Hi,
I am struggling with the hibernate mapping for a mapping between two tables using a link table. I have the following tables:

customer - customer_key, forename, surname, email
card - card_key, card_number, valid_from, expiries
customer-card - customer_card_key, customer_key, card_key

My mapping file is:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class entity-name="card" table="card" lazy="false">
<id name="id" column="card_key" type="integer">
<generator class="native" />
</id>
<property name="cardNumber" column="cardNumber" not-null="true" type="string" />
<property name="validFrom" column="valid_from" not-null="true" type="string" />
<property name="expires" column="expires" not-null="true" type="string" />
</class>

<class entity-name="customer" table="customer" lazy="false">
<id name="id" column="customer_key" type="integer">
<generator class="native" />
</id>
<property name="forename" column="forename" not-null="true" type="string" />
<property name="surname" column="surname" type="string" />
<property name="email" column="email" type="string" />
<idbag name="cards" table="customer-card">
<collection-id type="integer" column="customer_card_key" >
<generator class="native" />
</collection-id>
<key column="customer_key"/>
<many-to-many entity-name="card " column="card_key" fetch="select" />
</idbag>
</class>

</hibernate-mapping>

The error I get is:

org.hibernate.DuplicateMappingException: Duplicate class/entity mapping card
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
at org.hibernate.cfg.Configuration.add(Configuration.java:669)
at org.hibernate.cfg.Configuration.addXML(Configuration.java:440)

Please remember that I am using the dynamic mode MAP and not POJO.
Thanks for your help.
CTO


Top
 Profile  
 
 Post subject: Re: DynamicMode MAP - Link table
PostPosted: Fri Sep 14, 2007 8:41 am 
Newbie

Joined: Fri Sep 14, 2007 7:18 am
Posts: 2
I was being stupid and forgot how my application worked. Sorry.
Does anybody know of a good resource that covers Hibernate in DynamicMode MAP?
Thanks,
CTO


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.