ExtendedGormMappings Plugin
Dependency :
compile ":extended-gorm-mappings:0.4"
Summary
Installation
Install the plugin with the command:
grails install-plugin extended-gorm-mappings
Description
Introduction
This plugin adds extra options to the mapping closure in GORM domain classes. It includes a few mappings with the plugin, but it also provides the infrastructure for you to easily add mapping extensions in your own code.Built-in mappings
| Mapping | Data Type | Description |
|---|---|---|
| insertable | boolean | controls whether this column is included in INSERT statements |
| updateable | boolean | controls whether this column is included in UPDATE statements |
| formula | string | provides a SQL formula to be used in SELECT statements instead of binding this field to a database column. Implicitly makes the column read-only |
| Example: firstOrderDate formula: "(select min(o.creation_date) from Orders o where o.customer_id = id)" |
Version history
| Version | Changes |
|---|---|
| 0.3 | Insertable:false and Formula mappings now add a nullable:true constraint so you're not forced to enter a value you can't save. Formula mappings will no longer create a column if you're generating schema. Schema generation for Insertable:false mappings will no longer create columns as NOT NULL |
| 0.2 | Upgraded for grails 1.1.x |
| 0.1 | Initial release for grails 1.0.x |
How it works
Grails builds a Configuration and then uses that Configuration to create a SessionFactory. This plugin extends grail's ConfigurableLocalSessionFactoryBean and modifies the hibernate Configuration just before the SessionFactory is built.Creating your own mappings
Rather than hardcode a list of mapping extensions, this plugin queries the application context for any beans that implement the interfacepackage org.riskfactor.grails.gorm;import org.hibernate.mapping.Property;public interface GormExtension { void extend(GrailsDomainClass domainClass, Property prop, Object setting); String getKey(); }