3 Object Mapping - Reference Documentation
Authors: Graeme Rocher
Version: 5.0.8.RELEASE
3 Object Mapping
Object mapping works largely as described in the documentation on GORM. In general you can continue to model your associations using typical GORM notation such ashasMany
, belongsTo
and so on.The one notable exception is that the mapping block works differently to GORM for Hibernate. Most of the mapping configuration options available to GORM for Hibernate are specific to SQL databases and hence don't make sense to Redis.Here is an example of a domain class that can be persisted to Redis:class Person { String firstName String lastName static constraints = { firstName blank:false lastName blank:false } static mapping = { lastName index:true } }
lastName
property can be queried with a dynamic finder such as:Person.findByLastName("Simpson")
firstName
property cannot be queried and an error will be thrown if you attempt the equivalent dynamic finder for the firstName
property unless you specify index:true
for that property too.In other words, unlike SQL where every single property can be queried with Redis you must specify which properties can be queried up front.