-->
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 Key - repetaed column
PostPosted: Wed Aug 20, 2008 1:01 pm 
Beginner
Beginner

Joined: Sun May 07, 2006 2:44 pm
Posts: 33
Hey,

I have a composite key to user table.

so i have class for the composite-id - UserID (first,second)

I have class XXX like this:
1- the same pk like user
2- many to one to user.

in the many-to-one to the user i use in joincolumns like this:
@JoinColumns( { @JoinColumn(name = "first",referencedColumnName="first", @JoinColumn(name = "second",referencedColumnName="second") })

i get an exception:
repeated column for column- first
The same clumns are PK and FK.

Can you please advice.


Top
 Profile  
 
 Post subject: The classes
PostPosted: Wed Aug 20, 2008 1:22 pm 
Beginner
Beginner

Joined: Sun May 07, 2006 2:44 pm
Posts: 33
Code:
@Entity
public class Animal {   
@EmbeddedId   PK pk = new PK();      
@ManyToOne   
@JoinColumns( { @JoinColumn(name = "first",referencedColumnName="first"), @JoinColumn(name = "second",referencedColumnName="second") })
Owner owner;
}

@Entity
public class Owner {   
@EmbeddedId   PK pk = new PK();
}

public class PK implements Serializable{    
public String first;   
public String second;
}


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.