Search code examples
javadatabaseoracle-databasegrailsgrails-orm

Trying to run a simple dynamic scaffolding Grails app results in an ORA-00904 error


I'm trying to create a simple CRUD for a table in an Oracle 12 database so I created a Grails application, passed the database credentials in application.yml, created a controller and domain class named ConfigTest (the column is called CONFIG_TEST in the actual DB) and added some simple code to them.

The domain class:

package moduleprototype

class ConfigTest {
    int configid
    String name
    String type
    String value
    String description
    int status

    static constraints = {
    }
}

The controller:

package moduleprototype

class ConfigTestController {

    static scaffold = ConfigTest
}

The columns in my table are:

  • CONFIGID NUMBER
  • NAME VARCHAR2
  • TYPE VARCHAR2
  • VALUE CLOB
  • DESCRIPTION VARCHAR2
  • STATUS NUMBER

Thus, it looks like it should work but when I run the app and go to http://localhost:8080/ConfigTest, I get:

2019-01-08 15:06:28.552 ERROR --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ORA-00904: "THIS_"."VERSION": invalid identifier

2019-01-08 15:06:28.856 ERROR --- [nio-8080-exec-1] o.g.web.errors.GrailsExceptionResolver : OracleDatabaseException occurred when processing request: [GET] /ConfigTest ORA-00904: "THIS_"."VERSION": invalid identifier

Why is that so? What am I doing wrong? From what I gathered, errors like these are usually connected to naming problems but here, it seems like the names are OK and the model also follows the Grails name processing principles (or so it seems).

EDIT: I've also tried to do custom static mapping so as to be sure that everything maps to what I thought it did so I added this to the model class:

static mapping = {
    table 'CONFIG_TEST'

    configid column: 'CONFIGID'
    name column: 'NAME'
    type column: 'TYPE'
    value column: 'VALUE'
    description column: 'DESCRIPTION'
    status column: 'STATUS'

}

But it does not help at all, the same error persists :(


Solution

  • Grails expects a column named version on your table unless you disable it in the mapping block in your domain class like:

    static mapping = {
        version false
    }
    

    The version column is used for optimistic locking.

    See the docs for full info.