Posts

Making Composition in Grails GORM Work

Image
I felt that composition in GORM is a subject that required more information than what I found to be currently available. It is a very handy feature that can allow for a lot of flexibility and better code organization. Complex data types can be created and potentially shared by several domain classes across the project.  After some research on the Web, I picked up some useful bits of info. There were no complete examples available though, so I decided to go ahead and create my own. It took some experimentation on my part, but in the end, I made composition behave nicely in GORM. I created a GitHub repo with a very simple Grails project to showcase the complete working example. My goals for this sample project were as following: Organizing the project by placing the embedded class(es) in their own file(s). Doing so will make these class(es) available to all domain classes if the need arises. Fixing the scaffolded views to work with the embedded classes and their constraints. The