Issue Type: Bug Bug
Affects Versions: 4.2.2
Assignee: Unassigned
Attachments: CodeAndLogs.zip
Components: core
Created: 16/Jun/13 11:12 AM
Description:

I have an entity (User.class) which has a OneToMany relation (with a JoinColumn annotation) to another entity (Role.class), which has a composite Id.

I create a new User and a Role, and save them using session.saveOrUpdate(). The exact same user+role are already in the db, i expect this to work an have no effect, but i get a ConstraintViolationException.

If i change the JoinColumn annotation to include the nullable=false field, it works, but then adding a new user (which doesn't exist in the db) fails with a GenericJDBCException.

BTW - Loading a User entity, removing a Role associated with it and saving, fails with the GenericJDBCException, even without the nullable=false.

My entities and exceptions from the logs are attached.

Environment: Hibernate 4.2.2 as well as 4.1.4,
MySql 5.5
Mac OS X 10.8.4, Java 1.6.0
Project: Hibernate ORM
Priority: Major Major
Reporter: Gal Golan
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira