Grails, Technology

Using Hibernate Events with PersistenceEventListener

In my last blog, we discussed how to hook into GORM API to add some common custom functionality. We will refer the same problem that we discussed in my last blog. Here is the problem statement: In my grails plugin I was needed to add some fields that were common to a set of domains. For eg: for some domains we wanted to store fields like...

by Sandeep Poonia
Tag: GORM
23-Jul-2016

Grails

Hooking into the Instance methods of the GORM API

In my grails plugin I was needed to add some fields that were common to a set of domains. For eg: for some domains we wanted to store fields like createdBy and lastUpdatedBy to keep track of users who created and last updated each record in that domain. Grails framework provides timestamping using which we can keep track of the time a...

by Sandeep Poonia
Tag: GORM
30-Jan-2016

Database, Grails

Adding field to hasMany, got MySql error ??

It's a common practice to add fields to Grails domain's hasMany block while in database a foreign key relationship is maintained for every such entry. In other words, for each foreign key, we have a column in parent table (or domain) and a reference column in other table. I was adding a field into hasMany block recently when I got this...

by Ankit Agrawal
Tag: GORM
25-May-2015

Grails

Making a domain non-persistent

In grails app, there might come scenarios where one need to create a non-persistent domain rather than creating a command obejct or POJO / POGO. GORM comes with a handy static property mapWith which has default value GORM (which associates any domain with gorm persistence layer). To make a domain non persistent set mapWith="none". For...

by Vinay Prajapati
Tag: GORM
17-Apr-2015

Grails

Reusing grails Criteria for multiple domains using Closure.delegate

I recently had a situation where I had the exact same criteria in multiple domains. I found a way to DRY them using Closure.delegate. I wanted to share that in this post. Just including the relevant details the domains that I had were like the following. [code language="groovy"]class Subscription { static belongsTo = [topic:...

by Aseem Bansal
Tag: GORM
12-Apr-2015

Database, Grails

Grails unique constraint optimization part 2

In the previous blog Grails performance optimization - Unique constraint we have optimized Grails unique constraint. Now in this blog we will check another use case and will optimize unique constraint according to it. Suppose we have two domains having the following structure: [code] class Address { String addressLine1 String...

by Deepak Kumar Mittal
Tag: GORM
30-Dec-2014

Database, Grails

Grails performance optimization – Unique constraint

Grails unique constraint is very powerful way to check duplicate keys in any DBMS, but it has some impact on application performance. Lets check it by one example: Suppose we have one domain having the following structure: [code] class User { String firstName String lastName String emailId static constraints = { ...

by Deepak Kumar Mittal
Tag: GORM
20-Dec-2014

Grails

Day 3 at SpringOne 2GX 2014

Day 3 started sharp at 7:30 with the breakfast and then the sessions started from 8:30 AM and continued till 6:00 PM. The day was jam packed with varying sessions on Groovy, Grails, performance optimisation and the "Groovy puzzlers show" (Yes, it was a show ;) ). The highlights of the day were: #  Microservice Architecture With...

by Uday Pratap Singh
Tag: GORM
11-Sep-2014

Database, Grails

Alphanumeric Sorting using Criteria Query (with MySQL database)

I am working on a Grails application with MySQL database. I had a use case in which I had to implement alphanumeric sorting using Criteria Query on Grails. By alphanumeric sorting I mean if there is a class Employee with field empId then on doing : [plain] Employee e1 = new Employee(empId:'emp10').save() Employee e2 = new...

by Gaurav Sharma
Tag: GORM
02-Feb-2012

Grails

My Top 9 Features from Grails 2.0

The groovy world is abuzz about the latest release from the Grails Stable, Grails 2.0, which packs a lot more punch than its predecessors, which by themselves were productivity enhancers and wonderful to develop our web applications with. The new version brings with itself a lot of changes compared to the previous releases and...

by Vivek Krishna
Tag: GORM
18-Jan-2012

Database, 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: GORM
15-Apr-2011

Database, Grails

GORM Batch Deletes Made Easy with Load Method

We are using the grails asynchronous mail plugin in our project and noticed that the sent mails never gets deleted from the database. This was an issue because we were sending out a lot of mails and all of them had PDF attachments of about 500 KB to 1 MB each. A sure recipe for disaster because our DB was growing exponentially. To take...

by Vivek Krishna
Tag: GORM
29-Sep-2010