Happy Sunday gents, quick question, for GORM deriv...
# questions
p
Happy Sunday gents, quick question, for GORM derived properties (https://grails.github.io/legacy-gorm-doc/6.0.x/hibernate/manual/index.html#ormdsl 8.2.11. Derived Properties), does anybody know why they don't work with domain attribute names and instead the actual column names should be used? (e.g. domain fields are camelCase and fields in formulas should be snake_case). Thanks!
m
a "derived property" is the definition of a "hibernate formula". I'm not sure what language it is, because it's not sql or hql... I consider it to be sql, because you can use methods from the engine you use (sql server, mysql, oracle...)
p
I think I have read in HQL that the YEAR, MONTH, etc functions HQL don't implement are processed in the source DBMS, but if those are in hibernate, HQL is used (note those are the functions I use in my formulas), over a
timeCommitted
field that I need to write as
time_committed
in the formula. Though Grails doesn't allow to use class notation in the mapping formula, if you use the attribute name (camelCase) it fails with an exception when the formula is evaluated, and with the database column name (snake_case) it works. I think Grails is the one doing something strange here, and the mapping formula thing is not documented in deep IMO, I mean what it is, how it's evaluated, what should be used and what shouldn't.