To begin with, we are actually having this problem with NHibernate (don't shoot me), but I've also got parallel projects using Hibernate that will soon be crossing the same bridge.
We have a table where fields (non-primary key) cannot be updated. The primary key is an auto-generated integer. When looking at the SQL generated behind the scenes, it is putting the primary key field in the update statement. Below is a little snippet from our mapping:
We are simply trying to update F1002 and the SQL is failing (it is trying the statement UPDATE TblPartnership SET F1002='xxxx' and pshipID='xxx' where pshipid='xxx'). The Id field cannot be changed as it is a foreign key in many other tables.
Any ideas on how to fix this problem?
posted 8 years ago
You can try to add updatable = false in the id definition, although I think it should not be necessary.