When using session.saveOrUpdate(Object) Hibernate throws a ConstraintViolationException saying that I can not insert a duplicate value, which is what I would expect if I were using session.save(Object). But shouldn't the "update" part prevent this from happening and allow me to update an exisiting database entry? Is there another method for updating data with Hibernate? EDIT: I have to mention that it only happens with MySQL, I have used Hibernate before with SQLite and it didn't happen.
It depends on the constraints (primary and foreign key)... You need to post more code and DB structure. I have tried it and it works correctly - but it's important to make sure that you do not violate the constrains - for example by providing object with id set to null (in this case Hibernate will try to insert it as new item).