-->
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: Problem with composite-key and join
PostPosted: Thu Aug 18, 2011 6:51 am 
Newbie

Joined: Tue Jun 28, 2011 5:51 am
Posts: 2
Hi,
i know there are a lot of threads related to this topic but I couldn't get it to work so I want to ask for explicit help.

I have tables looking like that:

Table A:
id1: part of primary key
id2: part of primary key
fields...

Table B:
id1: primary key
fields...

Now I want to map those tables on one class:

Class Fields:
id1
id2
fields from A
fields from B

Its a many to one assiociation therefore there would be much more object representations than entrys in Table A.

My actuall mapping looks like this:

Code:
<class name="..." table="Table A">
         <composite-id name="id" class="...">
            <key-property name="id1"   column="..." type="integer"/>
            <key-property name="id2"   column="..." type="integer"/>
         </composite-id>
         
         <property name="..."   column="..."   type="..."/>

                   <join table="Table B">
            <key column="id1" property-ref="id1" />
            
            <property name="..."          column="..."         type="..."/>
         
            
         </join>
      
      </class>


I get the following error on executing:
Quote:
Foreign key (FK2448B63037B2D18C:TableB [id1])) must have same number of columns as the referenced primary key (Table A [id1,id2])


Without property-ref it's absolutly clear to me why this happens. With property-ref not! I do give him a column to join on, am I not?

Is there something I am missing?
How do I get the class mapped like I want it to be?
Is hibernate able to map a class like this?

I know the database schema is inappropriate but its a legacy system and it is absolutly no option to change it.
I appreciate every hint for a working solution.


Top
 Profile  
 
 Post subject: Re: Problem with composite-key and join
PostPosted: Fri Aug 26, 2011 6:22 am 
Newbie

Joined: Tue Jun 28, 2011 5:51 am
Posts: 2
Has nobody a hint for me?
I am not bound to the join keyword or anything. I am just bound to the database scheme and the need to map those two tables on one class. Everything else is flexible.


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.