Grails

Composite Key Domains won't be updated

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.0
  • Fix Version/s: 1.0.2
  • Component/s: Persistence
  • Labels:
    None

Description

Composite Key Domains won't be updated!!

Example:

class T implements Serializable {
static mapping = {
        id composite:['x', 'y']
    }
...

TController:

def update = {
        def T = T.get(new T(x:X.get(params.xid),y:Y.get(params.yid)))
        // Here I have my T Object!

 if (T) {
            // To set the properties is senseless! Hibernate doesn't perform an update
            T.properties = params
if (!T.hasErrors() && T.save(flush:true)) {
redirect...
}
} ....

After the work of the controller, nothing changed!! I tried it also with getting my T Object with findByXandY ..

Seems, that the Object hasn't been bound to the Hibernate session.

Activity

Hide
Graeme Rocher added a comment -

This works fine as far as I can see. I have written a test that verifies this behaviour:

http://svn.codehaus.org/grails/trunk/grails/test/groovy/org/codehaus/groovy/grails/orm/hibernate/CompositeIdentityUpdateTests.groovy

If it is the composite id fields you are trying to update that won't work, they're primary keys and not updateable

Show
Graeme Rocher added a comment - This works fine as far as I can see. I have written a test that verifies this behaviour:
http://svn.codehaus.org/grails/trunk/grails/test/groovy/org/codehaus/groovy/grails/orm/hibernate/CompositeIdentityUpdateTests.groovy
If it is the composite id fields you are trying to update that won't work, they're primary keys and not updateable
Hide
Graeme Rocher added a comment -

Bulk closing bunch of resolved issues

Show
Graeme Rocher added a comment - Bulk closing bunch of resolved issues

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: