1
나는 .. 별개의 내 list..this ..to 문제가 내 코드는이createCriteria와 별개의 목록을 만드는 방법은 무엇입니까?
도메인 :
:이 코드 도메인 은행에서 목록을 만들려면class City {
String city
static constraints = {
city(blank:false,unique:false)
}
}
class Financial {
String financial
String description
static constraints = {
financial(blank:false,unique:false)
}
}
class Bank {
Financial financial
City city
static constraints = {
financial(blank:false)
}
}
def index= {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
if(!params.sort && !params.order)
{
params.sort = "city"
params.order = "desc"
}
def c = Bank.createCriteria()
def results = c.list(params)
{
if(params.financial)
{
financial{
ilike("financial", "%${params.financial}%")s
}
}
}
[bankdetaillist: results,bankdetaillisttotal:results.totalCount, financial: params.financial?:""]
}
내가 은행, 예를 작성하는 경우 ..이 경우에서
Table bank :
id | version | city | financial
-------------------------------
0 | 0 | 1 | 1
1 | 0 | 5 | 1
, 우리가 알고있는 금융 1을 가진 은행은 많은 도시를 가지고 있습니다 ...
그리고 나는 재정적 인 분야에서 뚜렷한 은행에리스트하고 싶습니다.
?? 데프 금융 = Financial.findByFinancial (params.financial) \t \t 목록 banksForFin = Bank.findAllByFinancial (finRecord, [정렬 : "도시"순서 "내림차순"]) \t \t [bankdetaillist : banksForFin, bankdetaillisttotal : banksForFin.totalCount, financial : params.financial ?: ""] –
akiong
totalCount 대신 banksForFin.size()가 필요합니다. 또한 필 요한 경우 하드 코딩 된 값 대신 findAllBy 매개 변수 맵으로 params.sort/order를 대체하십시오. – shuttsy
내가 executeQuery를 사용할 수 있습니까? 아마 – akiong