Hibernate version: 2.1.8
Hi there,
i've got a question concerning the following method (@see EntityPersister):
Code:
protected String generateUpdateString(boolean[] includeProperty, Object[] oldFields) {
Update update = generateUpdate(includeProperty);
if ( optimisticLockMode()>Versioning.OPTIMISTIC_LOCK_VERSION && oldFields!=null ) {
boolean[] includeInWhere = optimisticLockMode()==Versioning.OPTIMISTIC_LOCK_ALL ?
getPropertyUpdateability() :
includeProperty;
for ( int i=0; i<getHydrateSpan(); i++ ) {
if ( includeInWhere[i] ) {
if ( oldFields[i]==null) {
update.addWhereColumns( propertyColumnNames[i], " is null");
}
else {
update.addWhereColumns( propertyColumnNames[i] );
}
}
}
}
return update.toStatementString();
}
For oldFields with value "null", a "is null" is written to the generated sql-String. In my case, where 'null'-values aren't allowed in db (legacy!) the update-Statement won't work!
My UserTypes will switch all default values (which are set instead of 'null') to 'null', which means that the oldFieldValues are 'null' in the POJO, but not in db.
Therefore, in my case, it's wrong to write "is null" ...
Sure i can subclass the EntityPersiter, i've done that, but this leads into copiing the complete code into a new class, just to change a few lines of code, because the EntityPersister isn't subclassable ...
My question (or my suggestion) is, why not 'ask' the Type if the value is really 'null'?
Or isn't that a problem with hb3? I haven't got the possibility to migrate at the moment, but it would be good to know :)
thx!
curio