GrailsJava/JVMTechnology

SQL Wildcards..is Your Application Safe?

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 […]

Technology

Write Criteria with has many String Types

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 […]

Kirti Nandwani
Kirti Nandwani
Read

Technology

Perform any DB operation in an isolated transaction

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 queuing operation etc.) […]

Grails

Extract correct class from hibernate object wrapped with javassist

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 many to many relationships […]

Sachin Verma
Sachin Verma
Read

Grails

Handling corrupted references through ignoreNotFound database mapping in Grails

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 […]

Grails

Grails: Get table name mapped to a domain

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 […]

Grails

A use case of Bitwise AND

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 […]

Mohd Farid
Mohd Farid
Read

Grails

Clearing Hibernate Query Cache in Grails

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. We found that this could be resolved by […]

Grails

Grails criteria query example for unidirectional one-to-many relationships

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 this can be: Employee.list().findAll{role in it.roles} This […]