我在hibernate中使用@Column注释时遇到异常

时间:2016-07-10 15:20:39

标签: hibernate

我在hibernate中使用@Column注释时遇到异常。

以下是例外情况:

   SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Hibernate: insert into USER_DETAILS (Permanent Address, description, Joined Date, Name, ID) values (?, ?, ?, ?, ?)
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
    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:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
    at org.hibernate.tutorial.manjosh.HibernateTest.main(HibernateTest.java:27)
Caused by: java.sql.BatchUpdateException: ORA-00917: missing comma

    at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10720)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    ... 8 more
`

2 个答案:

答案 0 :(得分:0)

请将您的插入更改为

insert into USER_DETAILS ('Permanent Address', 'description', 'Joined Date', 'Name', 'ID') values (?, ?, ?, ?, ?)

答案 1 :(得分:0)

请参阅此post

你基本上需要转义你的列名;但是,我建议避免使用这些类型的用途,以便您不需要使用此策略。