Reputation: 451
I am trying to trim a projection property but it does not let me do that.
def c = Book.createCriteria()
def books = c.list {
projections {
property ("title")
}
def now = new Date()
between('publishingDate', now-45, now+15)
}
I would like to trim the 'title' field in the criteria but it does not work. Any suggestions?
Upvotes: 1
Views: 674
Reputation: 66069
This will be possible in grails 2.2 using a sqlProjection
:
projections {
sqlProjection 'trim(title) as title', ['title'], [java.sql.Types.VARCHAR]
}
Upvotes: 2