hibernate annotations
iam executing hibernate anotation example in eclipse galileo iam getting the following error.
Hibernate: insert into employee1 (Name, ID) values (?, ?) Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update at org.hibernate.excep开发者_运维技巧tion.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
That means that the table doesn't exist :-) If you want Hibernate to automatically create and drop the tables, set the property hibernate.hbm2ddl.auto
to create-drop
. Also, I'd recommend reading Hibernate documentation, as it's one of the best sources for beginners.
http://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/configuration.html#setup-configuration
精彩评论