-->
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: composite id's question
PostPosted: Mon Jul 14, 2008 6:04 am 
Newbie

Joined: Sun Jul 01, 2007 12:15 pm
Posts: 7
Location: Philippines
I have a table that i need to map that does not have primary keys. The only 2 fields are used in many-to-one relationships.
So i used a composite id in my mapping:


<hibernate-mapping>
<class name="com.middle_table" table="middle_table">
<composite-id>
<key-property name="int_col1_id">
<column name="COL1"/>
</key-property>
<key-property name="int_col2_id">
<column name="COL2"/>
</key-property>
</composite-id>

<many-to-one name="col1_id" class="com.Col1" />
<many-to-one name="col2_id" class="com.Col2" />
</class>
</hibernate-mapping>


I added 2 int versions of the actual db field to my pojo. ex. Since col1_id is already used for a many-to-one association, i created an int_col1_id..

Now i'm having problems because i can't insert a new record into the table. It's saying col1_id is specified twice..

What is the right way to map a table with no primary keys in such way that i can insert new records into it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 14, 2008 10:19 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
What is the exact hibernateerror message you're getting? Could you post it?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.