-->
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.  [ 1 post ] 
Author Message
 Post subject: NonUniqueObjectException with unique composite key
PostPosted: Mon Sep 17, 2012 3:02 pm 
Newbie

Joined: Mon Sep 17, 2012 2:52 pm
Posts: 1
Hi,

I am getting this error when I attempt to save a child which has a unique composite key (sequence generated) but thesame PK. The issue only occurs when I try to save more than one child element with thesame child_key. Below is ths code. Please let me know any suggestions you may have. Been struggling with this for quite sometime now

@Entity
public class Parent implements Serializable {

@Column(name="PARENT_KEY", nullable=false)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ceremonyRecipientSeq")
@SequenceGenerator(name="ceremonyRecipientSeq", sequenceName="PARENT_KEY_SEQ")
private int parentKey

@OneToMany(cascade = {CascadeType.ALL})
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name = "PARENT_KEY", nullable=false)
private List<Child> children= new ArrayList<Child>();

//getter, setters
.....
}

@Entity
public class Child implements Serializable{

@Id
@Column(name="CHILD_KEY", nullable=false)
private String childKey;

//getter, setters
.....
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.