I am using a derived field in Grails domain class:
BigDecimal expectedDurationHrs
static mapping = {
expectedDurationHrs formula: 'time_to_sec(timediff(expected_end_date, expected_start_date )) / 3600'
}
This allows me to query for this duration. The problem is that when I make a change to the start or end date the derived property does not get updated even after .save(flush: true)
is called.
I would have expected after the save that the derived propert be updated. Similarly the domain instance stored in the Hibernate cache does not have the correct derived value.
Is there a way to have this refreshed and return the latest value?
cowper
I guess events can help to solve your problem. Take a look at beforeUpdate.