Sign in to edit and +1 items.
Login required
Download

Explicit Insert Plugin

(0)
Author(s)
Current Release    (3 years ago)
Grails Version ?
Tags persistence 
Dependency
compile ":explicit-insert:"
Last updated by admin 3 years ago
Last updated by admin 3 years ago
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

Last updated by seanwon 3 years ago
I have tried domain.save(insert:true), but it looks like not work. It still tell me "not found object with id xxx". (Grails 1.1 beta3 and grails 1.1 RC2)
Last updated by admin 3 years ago