|
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.
|