When I retrieve a "Table" object using session.find(), and it subsequently gets updated back to the database (even though I do not make any change to the table object anywhere). I get a "Attempt to insert NULL value into column 'DESCRIPTION', table 'clientdb.dbo.CDB_TABLE'" error as a result..
I can explain why Hibernate thinks the object is dirty: when I do the find, the HQL column name generated does not match the name in the mapping file:
HQL: from CDB_TABLE in class com.kbcam.core.entity.Table where CDB_TABLE.description = ?
SQL: select CDB_TABLE.tableId as tableId, CDB_TABLE.description as descript2_ from CDB_TABLE CDB_TABLE where (CDB_TABLE.description=? )
Note that in the generated SQL, the description column has been aliased as "descript2_" (ie truncated) so it does not get matched to the "description" attribute in the class.
My question is this: how do I prevent the QueryTranslator from truncating the name to produce a shortened alias name?
Alternatively, do I have to change the mapping files?? (This is not as good for me, because the mapping files are generated automatically using XDoclet, God bless it)
|