We all have search functionality in our applications. It is one of the most core features you would find ranging from searching for users, products, companies, etc. But are you sure your search functionality is doing exactly what it is supposed to do? You might have written test cases for it as well. But still, there are things...
Taking further this scenario, what if we need to query for partial matches of String, like just 'rai' not 'grails'. We face many issues while creating criteria with has many relationship on String types as normal way of querying doesn't work with has many relationship for String types. One way of getting this done is to use HQL....
Hi Friends, Sometimes we need to perform any DB operation in between a transaction, but due to transaction's property, it's getting committed only once the parent transaction will be finished. If you need to perform any operation that need to be committed immediately, irrespective of parent transaction (Example : for a dependent...
Hi, Some times when we access domain objects of collections in one to many or many to many relationships, we get Hibernate class wrapped with javassist, basically hibernate wraps all loaded objects with javassist after loading(lazy loading case) them . So if we call class.name on the members of collections in one to many or...
Hi, Recently i had a use-case where we have the legacy database and it contains the corrupted references of a non existent record in many-to-one relationship, and i have to populate a grid that contain info also from referenced record. As referenced record doesn't exist, So when we refer to the certain record will result in...
Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to provide backward...
Recently, I used bitwise Anding in my grails project. I am sharing the approach that we followed by means of an example. Suppose we have a domain class Person which can have multiple attributes like Smart, Intelligent, Talkative etc. What sort of relationship comes to our mind when we see this? I believe the obvious answer would...
In one of the projects, we had used Query Caching to improve the performance. However, it also meant that the updates/inserts into a table did not get reflected immediately, i.e. something like: DomainClass.findByPropertyName("propertyName", [cache: true]) returned the same list as it was, before the insertion/updation took place....
Following is an example of unidirectional one-to-many relationship: class Employee { String name static hasMany = [roles: Role] } class Role { String name } How can we find all the employees with a particular role - "Grails Developer"? Role role = Role.findByName("Grails Developer") One way of doing...