-->
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.  [ 3 posts ] 
Author Message
 Post subject: Strange Many-to-Many mapping problem
PostPosted: Thu Sep 02, 2004 12:39 pm 
Newbie

Joined: Fri May 14, 2004 5:38 pm
Posts: 12
Hibernate version:2.1

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

<hibernate-mapping>

<class name="com.foo.TaxAllocation" table="TAX_ALLOCATION" mutable="false" lazy="true">

<composite-id>
<key-property name="participantId" column="PARTC_ID"/>
<key-property name="betaTradeSymbol" column="BETA_TRADE_SYM" />
<key-property name="taxCode" column="TAXCODE_NUM" />
</composite-id>

<property name="allocationPercentage" column="ALLOC_PC" />
<set name="taxRates" table="TAX_ALLOC_WITHHOLDING" lazy="true">
<key>
<column name="PARTC_ID" />
<column name="BETA_TRADE_SYM" />
<column name="TAXCODE_NUM" />
</key>
<composite-element class="com.foo.TaxRate">
<many-to-one name="taxCodeRate" class="com.schwab.sps.domain.TaxCodeRate" >
<column name="TAXCODE_NUM" />
<column name="RATE_TYPE" />
</many-to-one>
<property name="ammountWithheldYTD" column="ALLOC_WITHLD_YTD" />
<property name="withholdISO" column="ALLOC_WITHLD_ISO" type="boolean" />
<property name="withholdNQ" column="ALLOC_WITHLD_NQ" type="boolean" />
<property name="withholdRES" column="ALLOC_WITHLD_RES" type="boolean" />
<property name="withholdSAR" column="ALLOC_WITHLD_SAR" type="boolean" />
</composite-element>
</set>

</class>


</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9


I am trying to map a legacy database which is really strangely set up. I have a many-to-many relationship between two objects. The association table has some data in it that I need as well.. so I am trying to set up a composite element type many-to-many mapping. THe problem is that foreign key to the first table is a compound key that shares one of it's components with the foreign key to the other table (no real foreign key constraints were created in the db). When I try to map it, hibernate complains that I have already used one of the columns. Is there any way to get hibernate to do this?

thanks!

joe


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 2:16 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you have to set update & insert elements = false for one of the property

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 2:49 pm 
Newbie

Joined: Fri May 14, 2004 5:38 pm
Posts: 12
Hi,

when I try to do the following:

<many-to-one name="taxCodeRate" class="com.schwab.sps.domain.TaxCodeRate" insert="false" update="false">


I get an error that claims that I can't use insert=false and update=false in a many-to-one relationship inside a component.

Is there somehwere else I can put those statements?

thanks!

joe


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.