-->
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 primary key and Foreign key having th
PostPosted: Tue Jul 16, 2013 1:19 pm 
Newbie

Joined: Tue Jul 16, 2013 1:17 pm
Posts: 1
I have problem with composite primary key and Foreign key having the same column.

Example

Table A PK (ID , NEW_ID)

Table B PK (ID, NEW_ID) FK (A_ID, NEW_ID)

when I used the below way in the child B when referring A

@ManyToOne
@JoinColumns({@JoinColumn(name = "A_ID", referencedColumnName = "ID"),
@JoinColumn(name = "NEW_ID", referencedColumnName = "NEW_ID")})
When I try to save B. I am getting an error of invalid Index.

So I am guessing it was also trying to set NEW_ID two times and getting this error.

I have no option to set one column as insertable and updatable as false.

Can any one help me in this


Top
 Profile  
 
 Post subject: Re: problem with composite primary key and Foreign key having th
PostPosted: Thu Jul 18, 2013 3:31 am 
Beginner
Beginner

Joined: Wed Feb 06, 2013 2:43 am
Posts: 46
I think there is a mistake in your many to one definition
you need to give the class name too like :

@ManyToOne(targetEntity = A.class)
@JoinColumns({@JoinColumn(name = "A_ID", referencedColumnName = "ID"),
@JoinColumn(name = "NEW_ID", referencedColumnName = "NEW_ID")})

_________________
Thanks,
Ajit Singh
ajits@mindfiresolutions.com
www.mindfiresolutions.com


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.