我们正在使用Grails 2.3.11和joda-time插件1.4。
我试图使用像这样的where查询:
Form.where { year(dateCreated) == currYear }.list()
在此currYear
是一个整数,dateCreated
的类型为org.joda.time.DateTime
结果就是这个例外:
org.springframework.dao.InvalidDataAccessResourceUsageException: Unsupported function [year] defined in query for property [datum] with type [class org.joda.time.DateTime]
at org.grails.datastore.gorm.finders.DynamicFinder.applyDetachedCriteria(DynamicFinder.java:440)
at grails.gorm.DetachedCriteria.withPopulatedQuery_closure10(DetachedCriteria.groovy:1201)
at org.grails.datastore.gorm.GormStaticApi.withDatastoreSession_closure23(GormStaticApi.groovy:699)
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:302)
at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:37)
at org.grails.datastore.gorm.GormStaticApi.withDatastoreSession(GormStaticApi.groovy:698)
at grails.gorm.DetachedCriteria.withPopulatedQuery(DetachedCriteria.groovy:1185)
at grails.gorm.DetachedCriteria.list(DetachedCriteria.groovy:845)
at grails.gorm.DetachedCriteria.list(DetachedCriteria.groovy:844)
使用joda-time时似乎不支持像year()这样的函数。 它是否正确? 或者我做错了什么?
在joda-time插件中添加对此的支持有多难? 或者在其他地方?