-->
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: @IdClass, composite key and @OneToMany relationship problem
PostPosted: Fri Mar 02, 2007 5:02 pm 
Newbie

Joined: Fri Mar 02, 2007 4:32 pm
Posts: 6
I am having a problem trying to use an Entity as a part of composite PK.
I am using separate class for @Embeddable PK and my example is similar to Footballer – FootballerPk example.
I am trying to have Country as a part of PK.
I am getting:
Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [com.alarm.indicators.Indicator]

Hibernate trace is saying:
Hibernate: insert into TBL_INDICATOR (name, code, country) values (?, ?, ?)



Here is my java code:

@Entity
public class Country implements Serializable{

private String name;

@Id
private String countryCodeIso2lt;

//… getters and setters




@Entity
@Table(name="TBL_INDICATOR")
@IdClass(IndicatorPk.class)
public class Indicator implements Serializable {

@Id
private String code;

private String name;

@Id
@ManyToOne
private Country country;
//… getters and setters




@Embeddable
public class IndicatorPk implements Serializable{

private String code;

private Country country;
//… getters and setters


What am I doing wrong?
Any help appreciated…


Top
 Profile  
 
 Post subject: Please ignore - wrong forum :(
PostPosted: Fri Mar 02, 2007 5:05 pm 
Newbie

Joined: Fri Mar 02, 2007 4:32 pm
Posts: 6
Sorry, it seems this has gone to wrong forum.
Reposting to Java Persistence...


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.