1. 程式人生 > >grails查詢指定列

grails查詢指定列

grails查詢指定列

grails查詢指定列,且以map的形式返回結果集,有兩種方式:

1、select new map(id as id,name as name) from User

2、User.createCriteria().list{

projections{

property("id","aliasId")

property("name","aliasName")

}

    setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP)

}



grails查詢指定列