I have a domain with a calculated field.
durationInMinutes formula: 'datepart(minute, Duration) + datepart(hour, Duration) * 60'
and use it in a createCriteria
property('durationInMinutes')
but this generates an error in the logfile
java.sql.SQLException: 'this_.minute' is not a recognized datepart option.
Please help. I use MySQL.
Found this working solution:
projections {
sqlProjection '(datepart(minute, Duration) + datepart(hour, Duration) * 60) as TimeInMinutes', 'TimeInMinutes', INTEGER
I am using the MySQL database, but I think it is a hibernate releated question?