我正在使用 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 来“清理”我从数据库收到的中间初始值,如果它是空的:
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 后,列出数据库中的所有学生就可以了。这对我来说没有任何意义,因为它不像我试图更新或保存对象到数据库。谁能解释发生了什么以及我该如何解决?