NonUniqueObjectException « Oracle « JPA Q&A

1. Multiple Primary Keys Table - Hibernate NonUniqueObjectException

I have a table with 2 primary keys (so the combination of both of them should be unique). The schema is like this:


2. NonUniqueObjectException in oracle

class: public class ParentPO { private java.util.List children; private long id; public ParentPO() { } public long getId() { return id; } public void setId(long id) { = id; } public java.util.List getChildren() { return children; } public void setChildren(java.util.List children) { this.children = children; } } public class ChildPO { private ParentPO parent; private long id; public ChildPO() { ...

3. NonUniqueObjectException when migrating Oracle to SQLServer

Issue: I am migrating hibernate+spring+tomcat application from oracle10g to sqlserver2005. The application is working fine in oracle. I changed the mapping files i.e, id generation from sequence to identity. It works fine except in a case where a unsaved parent(having null id) has two child records(having null id). In this case while saving, hibernate throws org.springframework.web.util.NestedServletException: Request processing failed; nested exception ...