iam 在 eclipse galileo iam 中执行 hibernate 注释示例时出现以下错误。
Hibernate: insert into employee1 (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:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at net.roseindia.Example1.main(Example1.java:22) Caused by: java.sql.BatchUpdateException: Table 'test.employee1' doesn't exist at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1566) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246) ... 8 more
最佳答案
Caused by: java.sql.BatchUpdateException: Table 'test.employee1' doesn't exist
这意味着该表不存在:-) 如果您希望 Hibernate 自动创建和删除表,请将属性 hibernate.hbm2ddl.auto
设置为 create-drop
。另外,我建议阅读 Hibernate 文档,因为它是初学者的最佳来源之一。
关于java - hibernate 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5191237/