java - hibernate 注释

标签 java eclipse hibernate

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 文档,因为它是初学者的最佳来源之一。

http://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/configuration.html#setup-configuration

关于java - hibernate 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5191237/

相关文章:

java - 在 QA 和 PROD 中部署时,url 大小超过一定限制时出现 403 错误

java - Swing 应用程序窗口未显示更改

java - hibernate 异常。查询语法异常 : unexpected token: HAVING

Java Socket/SocksSocketImpl 内存堵塞

java - System.out.println() 更改单线程程序中变量的值

java - 为什么我的 Eclipse Maven 控制台日志中都是来自 Guice 的 "binding"垃圾?

java - Eclipse 代码完成 (Java)/IntelliSense,类似于 Visual Studio (C#)

java - 无法获取 JSON 中的嵌套对象列表

java - JavaFX 中的 Hibernate - 显示来自所选 ID 的记录

Java8 Stream批处理以避免OutOfMemory