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...
View ArticleGrails – No such property for class:...
Behind that obscure title lies a problem that I recently had with Grails and that consumed half of my morning. The solution was rather simple but finding it was hard for me (although once it has...
View ArticleGrails – Is my bean a singleton?
At an interesting discussion about how to bulk-delete objects in Grails, I suggested using the sessionFactory bean to explicitly flush the session when required. One of the participants was concerned...
View ArticleGrails – query or criteria against a string/value pairs map property
Grails has a feature that I find sometimes useful: mapping a simple map of string/value pairs using GORM. That is, given a domain class, if you create a property whose type is Map, and the name of the...
View ArticleGrails – my domain class instance says its class is abstract!
I recently faced a weird problem when using Grails and a domain class hierarchy that contained abstract classes, let’s say: abstract class A { ...} abstract class B extends C { ...} class C extends A {...
View ArticleGrails – 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...
View ArticleGroovy – 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...
View ArticleGrails – publish a plugin in a self-hosted maven repository
Context and motivations Since a few versions ago, grails includes the possibility of packaging your plugin as an old good JAR file. This can be done by using the –binary option: grails-timestamped $...
View ArticleNew Grails plugin – Timestamped
Plugin URL: grails.org/plugin/timestamped Plugin documentation: deigote.github.io/grails-timestamped/guide/single.html Demo project with integration tests: github.com/deigote/TimestampedDemo I...
View ArticleGrails – small and simple method to convert objects to JSON
I was playing around with Grails and JSON and came up with a small method to convert a given collection of objects into JSON (typically, domain class objects, but it would work with anything). It’s...
View Article