wood burning stoves 2.0*
The moose likes Groovy and the fly likes unique constraints error under grails application using hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "unique constraints error under grails application using hibernate" Watch "unique constraints error under grails application using hibernate" New topic
Author

unique constraints error under grails application using hibernate

m bayloon
Greenhorn

Joined: May 28, 2012
Posts: 1
see this link
i have grails application using hibernate to create database

under grails 1.3.7 everything works properly

but when i switch to grails 2.0.3 the following problem appears

i can't check for unique fields under java/src directory. if i try to add or update any record with the same unique key, batch insert error appears

i try to use this reference but nothing change REFERENCE

under src/groovy i create a class to check validation

Example: LanguageCommand.groovy

package myproject.command

import org.codehaus.groovy.grails.validation.Validateable;

@Validateable
class LanguageCommand {

String code
String codeDescription

static constraints= {
code(blank:false, maxSize:50)
codeDescription(maxSize:200)
}
}

and under src/java i create a class to check for unique fields

Example: LanguageConstraints.groovy

package myproject.model

constraints = {
code unique: true
}

where myproject.model is the name of the package that contains hibernate classes

Note: Validation class works fine but the unique one not. i try to add unique constraints to validation class, same error appears

Error:

Error 500: Executing action [save] of controller [myproject.controller.LanguageController] caused exception: Runtime error executing action
Servlet: grails
URI: /myproject/grails/language/save.dispatch
Exception Message: Batch entry 0 insert into language (language_code, code_description, version, id) values (en, English, 0, 1) was aborted. Call getNextException to see the cause.
Caused by: Batch entry 0 insert into language (language_code, code_description, version, id) values (en, English, 0, 1) was aborted. Call getNextException to see the cause.
Class: LanguageController
At Line: [125]
Code Snippet:

any help?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unique constraints error under grails application using hibernate
 
Similar Threads
Hell with postgres + hibernate
getNextException SQLGrammarException
java.sql.BatchUpdateException
Key is not present in table error hibernate
onetoone unidirectional relationship problem