I'm facing the same issue with Hibernate 3.1.2.
We also have a case-insensitive database instance (SQLServer 2000).
This is an application that has been used for more than a year now. I discovered the problem when trying to fix some weird bugs.
We've managed all the cases for the PK creation or search by forcing upper case input.
The problem comes from other entities FK pointing on those case-sensitive PK.
I was horrified when looking up in the db for those FK column and realizing that for a same ID, say #C300 I could find references like #c300 and #C300.
This works perfectly when firing HIbernate generated queries on the SQLServer instance.
But Hibernate itself is case-sensitive and check this in the AbstractType class method:
Code:
public boolean isEqual(Object x, Object y, EntityMode entityMode, SessionFactoryImplementor factory) {
return isEqual(x, y, entityMode);
}
The question is how come some FK became lower-case when the entity ID itself is using upper-case???? Some table containing those FK are index table for NtoN relationships, meaning entirely controled by Hibernate.
So, it seems that Hibernate itself would be responsible for this behavior. I haven't be able to reproduce the behavior yet.
For now the easiest solution to fix my bug would be to change is isEqual method to be case-insensitive. I won't dare to do that since I have no idea on how it is used, but if possible, that'd be a very quick fix.
The only other way is to find all lower case references in the DB and change them. That's going to be a HUGE amount of work. Then make the DB itself case-sentitive and track the errors...
The kind of exception i get from this lower case FK:
Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.xx.common.model.of.OrganismeFormation#c300]