Hibernate version:
Hibernate 3.2.6
Hibernate Annotations 3.3.1.GA
Hibernate EntityManager 3.3.2.GA
Name and version of the database you are using:
PostGreSQL Database Server 8.3
Hello,
i prepared a rather complex Entitystructure and annotated each entity (hopefully) correctla with the following Annotations on the Getter-Methods of the objects:
Code:
@OneToOne(cascade={CascadeType.ALL})
@OnDelete(action=OnDeleteAction.CASCADE)
the lists i use are annotated this way:
Code:
@OneToMany(cascade={CascadeType.ALL})
when i now EntityManager em.merge() the root object the merge run is completed sucessfully, but if i have a look at the databse after this, there are multiple entrys for objects that are equal. Just the id is different.
SmallExample:
Child class:
Code:
@Entity
public class DialTime {
...(some payload)
private Long id;
@Id@GeneratedValue
public Long getId() {
return id;
}
private void setId(Long id) {
this.id = id;
}
Parent class:
Code:
@Entity
public class DialDate{
....
private DialTime dialTime;
private Long id;
public DialDate(){
dialTime= new DialTime();
}
@Id @GeneratedValue
public Long getId() {
return id;
}
@OneToOne(cascade={CascadeType.ALL})
@OnDelete(action=OnDeleteAction.CASCADE)
public DialTime getDialTime() {
return dialTime;
}
if i than em.merge(new DialDate())
with several dates there are some entrys in the DB-Table in PostGreSQL with show equal DialTime and even equal DialDate enrys only differing by the id column.
Is there a way to avoid this and only persist Instances that vary in other values than simply the id?
Or should i not instnciate "empty" objects?
As i undestood from reading the merge() does look if there is already a object fitting and replacing the foreign key as needed...
thanx for the help(and sorry for bad english)
[/code]