Question

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?

Was it helpful?

Solution

This will be possible in grails 2.2 using a sqlProjection:

projections {
    sqlProjection 'trim(title) as title', ['title'], [java.sql.Types.VARCHAR]
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top