I'm not really sure how the best way to do this is. I'm not very familiar with Hibernate internals. Actually, haven't l needed to look at them until today. :)
In short, EntityPersister.toColumns (the version that takes a property name) is not able to look up the formula property using getPropertyColumnNames().
getPropertyColumnNames looks in the columnNamesByPropertyPath Hashtable that's from EntityPersister's superclass, AbstractEntityPersister.
Now, propertyColumnNames doesn't have the formula in it because EntityPersister only places properties in it f they AREN'T formulas.
So, the questions I have for you are:
Do you want to consider the formula a column name within EntityPersister?
Okay, what I've done, that works, is to alter keep track of which properties are formulas by adding a new closure list and putting the property names in for formulas. Then, when toColumns can't find the column, it looks through the list of formula properties again, finds it, and looks up the actual formula text from the closure.
It seems to work for now. I'm sure there's a much, much better way to do it, though. Do you want a patch, or do you want to do a more proper job yourself?
|