Grails, Java

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...

by Sachin Gulati
Tag: hibernate
18-May-2017

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 to use HQL....

by Kirti Nandwani
Tag: hibernate
13-Sep-2015

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...

by Anil Agarwal
Tag: hibernate
28-Jul-2015

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...

by Sachin Verma
Tag: hibernate
21-Sep-2012

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 result in...

by Tarun Pareek
Tag: hibernate
17-Apr-2012

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 provide backward...

by Roni C. Thomas
Tag: hibernate
19-Aug-2011

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 answer would...

by Mohd Farid
Tag: hibernate
15-Apr-2011

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....

by Vivek Krishna
Tag: hibernate
23-Jun-2010

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...

by Aman Aggarwal
Tag: hibernate
14-Jun-2010