Hi, For problems with Hibernate, it's probably better to ask at StackOverflow.com. Maybe you want to test with another database as well, for example Apache Derby or PostgreSQL.
We would need a simple, reproducible test case. If you are using Hibernate or another ORM tool, you could append ";trace_level_file=3" to the database, in order to get the complete list of JDBC API calls. Regards, Thomas On Tuesday, March 10, 2015, Radim Vansa <[email protected]> wrote: > 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] > <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- 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.
