Row was updated or deleted by another transaction

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Row was updated or deleted by another transaction

Pavel Sergeev
Hello, All

I have a domain class:
//////
package admin

class Settings {

static mapping = {
table 'SETTINGS'
version false
//name column : 'PARAMNAME'
value column : 'PARAMVALUE'
description column : 'DESCRIPTION'
id name: 'name', column : 'PARAMNAME'

}
String name;
String value;
String description;

static constraints = {
name maxSize: 150;
value maxSize: 150;
description  maxSize: 1024;
}
}
/////

and I have an empty controller with static scaffold = true
When I am trying to save record a error is happened:
------------------
Class: org.hibernate.StaleObjectStateException
Message: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [admin.Settings#1]
189:				chain.doFilter(request, response);
63:				doFilter(request, response, chain);

Trace

    Line | Method
->>   38 | $tt__save in SettingsController.groovy
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    189 | doFilter  in PageFragmentCachingFilter.java
|     63 | doFilter  in AbstractFilter.java
|   1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread
-----------------

I run my application in a dev mode with default datasource settings:
///
dataSource {
    pooled = true
    jmxExport = true
    driverClassName = "org.h2.Driver"
    username = "sa"
    password = ""
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
//    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
    singleSession = true // configure OSIV singleSession mode
}

// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
    }
    .....
////

If I change code of domain class:
name column : 'PARAMNAME'
value column : 'PARAMVALUE'
description column : 'DESCRIPTION'
//id name: 'name', column : 'PARAMNAME'

than there is no errors.

What can I do to fix the problem?



--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/27ed5e67-e4aa-41e1-8994-e7bb43ade4d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Row was updated or deleted by another transaction

Pavel Sergeev


What can I do to fix the problem?



UPD 
def mysave() {
def s = new SmsSettings(name: "1", value: "1", description: "1")
s.save(flush: true);
this method of controller gives same error

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/28cd9f35-ef93-4e18-915b-695e0a818c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Row was updated or deleted by another transaction

micke_
What happens if you get rid of the "column" attribute  in the first example? At a glance it looks like you are referring to a column which is not mapped to the the "name" field.
Ex:
id name: 'name'


On 17 November 2014 13:28, Pavel Sergeev <[hidden email]> wrote:


What can I do to fix the problem?



UPD 
def mysave() {
def s = new SmsSettings(name: "1", value: "1", description: "1")
s.save(flush: true);
this method of controller gives same error

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/28cd9f35-ef93-4e18-915b-695e0a818c8d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMPMOdZM%3D%2BcZP4vzo85MFvhGkTqfUQmePH9a%2BfM7Nfv6Lwd93g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Row was updated or deleted by another transaction

Pavel Sergeev


On Monday, November 17, 2014 11:50:13 PM UTC+4, Mikael Andersson wrote:
What happens if you get rid of the "column" attribute  in the first example? At a glance it looks like you are referring to a column which is not mapped to the the "name" field.
Ex:
id name: 'name'


static mapping = {
table 'SETTINGS'
version false
//name column : 'PARAMNAME'
value column : 'PARAMVALUE'
description column : 'DESCRIPTION'
//id name: 'name', column : 'PARAMNAME'
id name: 'name'

}
This get same error + column 'NAME' instead 'PARAMNAME'.
Perhaps, I didn't understand your thought.
 

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/ebbf3e37-64c3-4fac-8d13-fa925a391891%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Row was updated or deleted by another transaction

Pavel Sergeev
In reply to this post by Pavel Sergeev
RESOLVED:

this is the working code:

static mapping = {
table 'SETTINGS'
version false
name column : 'PARAMNAME'
value column : 'PARAMVALUE'
description column : 'DESCRIPTION'
id name: 'name', generator: 'assigned', type: 'string'
}
but scaffolding doesn't work properly.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/dae85cd1-5c49-40f4-86ee-4e20379ce350%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Row was updated or deleted by another transaction

Oliver Trieu


Am Mittwoch, 19. November 2014 08:36:35 UTC+1 schrieb Pavel Sergeev:
RESOLVED:

this is the working code:

static mapping = {
table 'SETTINGS'
version false
name column : 'PARAMNAME'
value column : 'PARAMVALUE'
description column : 'DESCRIPTION'
id name: 'name', generator: 'assigned', type: 'string'
}
but scaffolding doesn't work properly.

I recommend against using a custom id column in grails. Like you already saw, scaffolding will run into problems and so will many other things.
We did this to a DomainClass in our Project and we payed the price for this on several occasions. In our case we had a table of countries following the ISO standard and we wanted the country code to be the key. 
Thru the entire project this has caused trouble in various areas so i guess its better to go with the standard id column if possible. 

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/46bf3a24-ae82-4639-b5d5-115840177d78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.