Explicit Insert Plugin

  • Tags: persistence
  • Latest:
  • Last Updated: 27 March 2009
  • Grails version: *
  • Authors: Marc Palmer
0 vote
Dependency:
compile ":explicit-insert:"

Summary

Description

Many legacy database files have composite keys and they rarely have a version number or timestamp. The GORM Mapping DSL is fantastic but the Composite ID has an issue when creating a new row. The domain.save() operation causes an SQL update. The problem arises when the version facility is turned off (via version:false) and the Hibernate generator is set to 'assigned' (id generator:'assigned') -- Hibernate is not able to sense that an insert is required.

This plugin adds a method called insert to all domain classes. It is up to the developer to predicate the call to save() or insert().

Note that Grails 1.0.2 provides a more elegant solution. The domain.save() method now accepts domain.save(insert:true) to explicitly predicate the insert operation. So use this plug-in only for Grails applications that are below version 1.0.2.

http://docs.codehaus.org/download/attachments/28213261/grails-explicit-insert-1.0-RC2-SNAPSHOT.zip