歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Hibernate列名是保留字的解決方法

Hibernate列名是保留字的解決方法

日期:2017/3/1 9:48:37   编辑:Linux編程

在Hibernate框架下,如果要操作的列名是Oracle的保留字,則會報如下的錯誤。

Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at com.accp.dao.impl.LoggerDaoImpl.addLogger(LoggerDaoImpl.java:21)
at com.accp.dao.impl.LoggerDaoImpl.main(LoggerDaoImpl.java:29)
Caused by: java.sql.BatchUpdateException:<STRONG><SPAN > <SPAN >ORA-00928: 缺失 SELECT 關鍵字</SPAN></SPAN></STRONG>

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:629)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9409)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:211)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 9 more

解決的辦法:在Hibernate配置文件中給關鍵字列加上[關鍵字列名]

<column length="500" name="[comment]" not-null="true" />

Hibernate 的詳細介紹:請點這裡
Hibernate 的下載地址:請點這裡

Hibernate 中文手冊 PDF http://www.linuxidc.com/Linux/2013-10/91208.htm

Copyright © Linux教程網 All Rights Reserved