grails

Grails - Hibernate-safe domain class property editor

Grails automatic databinding is super powerful, but, at least in versions 2.2.x and below, is rather obscure and not very-well documented. Sometimes is not clear how a form input should be named depending on what you want to bind. An example, for a given domain class User and a property roles (that is an association […]

Grails - query or criteria against a string/value pairs map property

Grails gives the possibility of creating simple key/value map properties as a Map of String to String, but the documentation doesn't show how to query by this type of properties. This post illustrates how to query the domain class using the map property as part of the query (i.e adding a condition for the key X to have the value Y) using HQL.

Grails - Quickly examine a domain class associations

When your Grails model gets a bit complex, you may find yourself with conflicts in your domain classes associations (I like some parts of GORM, such as dynamic finders, but I think the relationships stuff could be improved). In my case, I usually end up finding problems when I mix inheritance and different relationships between […]

Groovy - Simplest way of resolving a nested property

So let's say that in Groovy you find yourself wanting to do something like this: [ 'name', 'lastName', 'address.street'].collect { propertyToResolve -> [(propertyToResolve): user[property] } You will find that the automatic getter (using it with the map syntax or as a property doesn't change anything) won't parse the argument to resolve the property in the […]