I have a class Node
Node.java
public class WebPage implements BusinessObject {
@Id
private Long id;
@ManyToMany
@JoinTable(name = "childnodes")
private Set<WebPage> references; // nodes contained by this node
}
My requirements :
- One node can reference many nodes.
- One node can reference it self.
- One node can be referenced by many nodes or not.
I want to do something like this :
- Node A -> Node B (Node A references Node B and so on)
- Node A -> Node C
-
Node A -> Node D
-
Node B -> Node E
- Node B -> Node C
All steps run OK except the 5th one. I have an exception : Unique index or primary key violation: How can i tell Hibernate to DO NOT try to insert Node C but instead update it !
The problem was not on Hibernate behalf but on a bug in my code :\