Hi,
I am trying to map an entity to H2 (server mode) through JPA, with
Hibernate implementation. The entity is a simple node in binary tree, with
child nodes set to cascade all operations. When I call
entityManager.remove(node); the cascaded entries are correctly set for
removal; however when I call entityManager.flush(), the delete for entry
hits 'Referential integrity constraint violation:
"FK_UJOY3QEQHYBY34YBBXVHD13E: PUBLIC.NODE FOREIGN KEY(PARENT_ID) REFERENCES
PUBLIC.NODE(ID) (35399)"'
This looks like quite a simple usecase, but I miss to understand what am I
doing wrong. The hibernate.flushMode is set to COMMIT in persistence.xml.
Thanks for your clues.
This is the entity:
@Entity
public class Node {
@Id
@GeneratedValue
long id;
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.REFRESH }, fetch = FetchType.LAZY)
Node parent;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch =
FetchType.LAZY)
Node left;
int leftSize;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch =
FetchType.LAZY)
Node right;
int rightSize;
/* constructor, getters & setters */
}
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.