0
votes

I'm using GORM to create some domain classes for a plugin I will use across multiple Grails 2.2.3 applications. For some reason, when I add a Getter to my Student domain class I get a BatchUpdateException telling me I don't have sufficient privileges to update.

Edit: Note that I am using the ojdbc6-11.2.0.1.0 driver for Oracle 11g database.

Here is my Student class:

class Student {

    String sid
    String firstName
    String lastName
    String middleInitial
    String email
    String ssn

    static mapping = {
        // Mappings and such
    }
}

I am adding this Getter to "sanitize" the middle initial value I receive from the database on the chance that it is null:

String getMiddleInitial() {
    return this.middleInitial ?: ""
}

After adding that line, I navigate to the /$app_name/student/list URL and get the following error/stack trace:

Error 500: Internal Server Error

URI
/appname/employee/list
Class
java.sql.BatchUpdateException
Message
ORA-01031: insufficient privileges
Trace

   Line | Method
->> 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   918 | run     in     ''
^   680 | run . . in java.lang.Thread

Caused by SQLGrammarException: Could not execute JDBC batch update
->> 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   918 | run     in     ''
^   680 | run . . in java.lang.Thread

Caused by BatchUpdateException: ORA-01031: insufficient privileges

->> 10070 | executeBatch in oracle.jdbc.driver.OraclePreparedStatement
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   213 | executeBatch in oracle.jdbc.driver.OracleStatementWrapper
|   297 | executeBatch in org.apache.commons.dbcp.DelegatingStatement
|   895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run . . in     ''
^   680 | run     in java.lang.Thread

After removing that Getter, listing all of students in the database works just fine. This doesn't make any sense to me, because it isn't like I'm trying to update or save an object to the database. Can anyone explain what is going on and how I can fix it?

2

2 Answers

1
votes

Check if you have dbCreate set to update or create in DataSource.groovy?

If it is present, then remove or comment out that entry.

//dbCreate = 'update' //or use as below
dbCreate = 'none'
0
votes

I had similar problem while flushing the session after every 100 rows. I turned on the SQL logging and hibernate logging. It turned out to be the grails session is trying to persist the unnecessary domain object which is in the session. I had to discard the object using domainObj.discard() before flushing the session. Then this error disappered.