如何獲得它,所以我返回所有的預測從下面Grails的預測沒有返回的所有屬性,而不是分組
def c = Company.createCriteria()
def a = c.list(params){
projections{
property 'id', property 'name'
}
}
if(a.size() == 0)
render "404"
else {
render (contentType: 'text/json'){
totalCount = a.totalCount
data = a
}
}
結果出來是這樣的:
{「TOTALCOUNT」:2 「數據」:[ 「公司1」, 「Company2的」]}
其中i需要它是:
{ 「TOTALCOUNT」:2 「數據」:[{ 「類」:「有機example.Company 「 」ID「:1, 」名「: 」公司1「},{ 」類「:」 org.example.Com公司域名「,」id「:2,」name「:」company2「}]}
在公司域名中我有很多關係(一對一,一對多等) 我的域名外觀像下面這樣:
包org.example
進口的java.sql.Timestamp
class Company {
String name
String abn
String cname
String email
String phone
String position
String address
String city
String postcode
int style
int openbookings;
Date date;
int tokenTotal = 0
int totaltokens
int totalboosts
int totalposts
Timestamp tokenstamp
static hasMany = [users: User, broadcast: Broadcast, bookings: Booking, locations: Location,vimsurvey:VimSurvey,rewards: Reward, tokens: CompanyToken]
static constraints = {
abn nullable: true
date nullable: true
style nullable: true
}
}
任何幫助將是巨大的:) ????
有沒有找到答案?我有一個類似的問題在這裏http://stackoverflow.com/questions/15250974/createcriteria-with-projections-does-not-select-all-columns – Sap