Search code examples
grailsgrails-ormhibernate-criteria

How can I get all the data of one column in grails?


I'm new in grails and I'm trying to find the solution but I don't found any question here...

That I want to do is, I have this labels in my domain:

    String platform
    String appVersion
    String name
    String id

How can I get only all the data that I have store in appVersion column?


Solution

  • You can try the following code with your domain name

    def c = DomainName.createCriteria()
    def requiredList = c.list  { 
       projections {                    //projection does the trick
           property('appVersion')
       }
    }
    

    And if by chance you want to compare any value then:

    def c = DomainName.createCriteria()
    def requiredList = c.list { 
       eq('column_name', value_to_compare)
       projections {                    
           property('appVersion')
       }
    }