-->
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: Association with Foreign Key
PostPosted: Tue Mar 08, 2005 7:22 am 
Newbie

Joined: Tue Mar 08, 2005 7:16 am
Posts: 8
Hi all,

I'm hitting a problem when trying to create a one-to-many association on a column that is not the primary key. I have database 2 tables, Issuer and EquityRatio with the one-to-many from Issuer to EquityRatio. The column in Issuer is R1_TICKER and the column in EquityRatio is TICKER.

The problem we seem to be having is that when Hibernate is trying to map to the EquityRatio table it is passing in the primary key from Issuer instead of the R1_TICKER value. We can't seem to work out how to force Hibernate to use the R1_TICKER column instead of the primary key column. I've had a search on the forum but I can't find anything useful.

Any ideas? Full details below.

Rob

Hibernate version: 3.0

Mapping documents:

<set
name="equityRatios"
lazy="true"
cascade="none"
batch-size="10"

>
<key foreign-key="R1_TICKER" >
<column name="TICKER" />
</key>
<one-to-many
class="com.db.csa.domain.EquityRatio"
/>
</set

Full stack trace of any exception that occurs:
ORA-01722: invalid number ORA-02063: preceding line from CSATOR1

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

The generated SQL (show_sql=true):
select equityrati0_.TICKER as TICKER__, equityrati0_.RATIO as RATIO__, equityrati0_.VALUE as VALUE__, equityrati0_.REPORT_YEAR as REPORT4___, equityrati0_.TICKER as TICKER0_, equityrati0_.RATIO as RATIO0_, equityrati0_.VALUE as VALUE0_, equityrati0_.REPORT_YEAR as REPORT4_0_ from V_EQUITY_RATIO equityrati0_ where equityrati0_.TICKER=?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 14, 2005 3:29 pm 
Newbie

Joined: Thu Apr 14, 2005 3:21 pm
Posts: 1
I am currently running into the exact same problem, and unfortunately I'm coming to the conclusion that you can't do it. This statement in the 2.1.6 Hibernate Reference Documentation, page 45 (first page of Chapter 6) is what leads me to believe this: "Collection instances are distinguished in the database by a foreign key to the owning entity."

If you've found out a way to solve this problem, please post it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 15, 2005 8:17 am 
Newbie

Joined: Fri Apr 15, 2005 8:08 am
Posts: 6
hi, I use eclipse hibernate plug-in to connect DB in this situation and it works. However, I didn't specifiy foreign-key. The example is as the following:

<key>
<column name="TICKER" />
</key>


Try it.


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.