1
沒有爲Product
表分頁搜索。搜索查看Product
對象以及ProductParam
對象。正確分頁withCriteria而看多到一個表(Grails的)
的問題是有在搜索結果中重複的產品:具有25個項目每頁,三分之二被複制的產品。
如果在標準建造應用resultTransformer org.hibernate.Criteria.DISTINCT_ROOT_ENTITY,每頁導致項目超過25個少 - 這是關於6
在這兩種情況下,搜索被打破。這個問題能解決嗎? (如果沒有完全重寫代碼)
class Product {
String name
static hasMany = [ params: ProductParam ]
}
class ProductParam {
String key
String value
static belongsTo = [ product: Product ]
}
HibernateCriteriaBuilder criteriaBuilder = Product.createCriteria()
PagedResultList results = criteriaBuilder.list(max: 25, offset: offset) {
or {
// searching in Product
ilike 'name', "%${query}%"
// searching in ProductParam
createAlias('params', 'pp')
ilike 'pp.value', "%${query}%"
}
//resultTransformer org.hibernate.Criteria.DISTINCT_ROOT_ENTITY
}
的Grails 2.2.0,Postgres的
多少在總(忽略分頁),你希望如果查詢按預期工作? – dmahapatro