em.merge(course);    // course is a detached entity

I got the following exception:

org.hibernate.exception.ConstraintViolationException: could not insert: 
package.Course.

The exception means it tried to insert a new row for merge.

The detached entity was initially retrieved from database using

course = em.find(Course.class, 876L);   // the course id is 876.

It has a valid id.  (using debugger).

If I load the entity from database first, then merge it, it works.

em.find(Course.class, 876L);  
em.merge(course);   


I have been working on solving this for days. Any helps are appreciated.
Thanks
Dave


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044590#4044590

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044590
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to