Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails java.sql.BatchUpdateException使用Hibernate/GORM时出错_Hibernate_Exception_Grails_Gorm_Grails Domain Class - Fatal编程技术网

Grails java.sql.BatchUpdateException使用Hibernate/GORM时出错

Grails java.sql.BatchUpdateException使用Hibernate/GORM时出错,hibernate,exception,grails,gorm,grails-domain-class,Hibernate,Exception,Grails,Gorm,Grails Domain Class,我正在使用GORM为我将在多个Grails2.2.3应用程序中使用的插件创建一些域类。出于某种原因,当我向我的学生域类添加一个Getter时,我得到一个BatchUpdateException,告诉我我没有足够的权限进行更新 编辑:请注意,我正在使用Oracle11g数据库的ojdbc6-11.2.0.1.0驱动程序 这是我的学生课: class Student { String sid String firstName String lastName Stri

我正在使用GORM为我将在多个Grails2.2.3应用程序中使用的插件创建一些域类。出于某种原因,当我向我的学生域类添加一个Getter时,我得到一个BatchUpdateException,告诉我我没有足够的权限进行更新

编辑:请注意,我正在使用Oracle11g数据库的ojdbc6-11.2.0.1.0驱动程序

这是我的学生课:

class Student {

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

    static mapping = {
        // Mappings and such
    }
}
我添加此Getter是为了“清理”我从数据库收到的中间初始值(可能为null):

String getMiddleInitial() {
    return this.middleInitial ?: ""
}
添加该行后,我导航到
/$app\u name/student/list
URL并获得以下错误/堆栈跟踪:

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

删除该Getter之后,在数据库中列出所有学生就可以了。这对我来说没有任何意义,因为我并不是在尝试更新或将对象保存到数据库中。谁能解释一下发生了什么以及我如何修复它吗?

检查您是否在
数据源.groovy中将
dbCreate
设置为
update
create

如果存在,则删除或注释掉该条目

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

在每100行刷新一次会话时,我也遇到了类似的问题。我打开了SQL日志和hibernate日志。原来是grails会话试图持久化会话中不必要的域对象。在刷新会话之前,我必须使用domainObj.discard()放弃该对象。然后这个错误消失了。

我已经删除了它,但我可以尝试显式地将它设置为“无”。编辑:没有这样的运气。同样的错误。我认为Grails域类中支持getter和setter,如果您想对设置/返回的内容有一点额外的控制?@grantmc如果不使用
dbCreate
,这应该是个问题。我使用了
ojdbc14
,并按照上述相同的步骤解决了相同的问题。@grantmc您是在运行测试还是
运行应用程序
?检查您是否在适当的环境下发表评论。我已将其从所有环境中删除。我正在做一个跑步应用程序。似乎由于某种原因,添加了
静态瞬态=['middleInitial']
修复了它…@grantmc,但这与目的背道而驰
middleInitial
是映射到db中的列的域类属性,不应是暂时的。正确的?