Hi
In this blog I am going to explain you about some useful code in your grails/java, which you can use in your project for solving some problems.
First of all I am going to explain you about how to filter a domain class with other domain class refrence in that domain.
List users = User.createCriteria().list{
createAlias('detail', 'detail', Criteria.LEFT_JOIN)
not {'in'("detail", detail)}
eq("detail.isDeleted",false)
}
Something like that you can implement your own logic to filter the entries with other domain class refrence object.
In the above code we first joing the current table with the refrence table and creating an alias of that domain class and then checking the values on that alias.
Second one is paginating the domain class objects with grails default pagination.
We can paginate the result by passing a map to the domain list method like this
Map map = [offset: offsetValue, max: maxValue, order: orderValue(asc/desc), sort: sortAttribute] Listusers = User.list(map)
In the above code we are providing some constraints to the domain class according to the requirement of the data.
Hope it helps!
THANKS
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Shakil Pathan
Shakil is an experienced Groovy and Grails developer . He has also worked extensively on developing STB applications using NetGem .