gpt4 book ai didi

hibernate - 使用Hibernate/GORM导致java.sql.BatchUpdateException错误

转载 作者:行者123 更新时间:2023-12-02 15:32:14 25 4
gpt4 key购买 nike

我正在使用GORM为将在多个Grails 2.2.3应用程序中使用的插件创建一些域类。出于某种原因,当我将Getter添加到我的Student域类中时,我得到一个BatchUpdateException告诉我我没有足够的特权来更新。

编辑:请注意,我正在使用Oracle 11g数据库的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_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之后,列出数据库中的所有学生就可以了。这对我来说没有任何意义,因为这与我试图将对象更新或保存到数据库中不同。谁能解释发生了什么事以及如何解决?

最佳答案

检查是否已将dbCreate设置为updatecreate中的DataSource.groovy

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

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

关于hibernate - 使用Hibernate/GORM导致java.sql.BatchUpdateException错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17659187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com