Hi,
For some reason it seems that none of "hibernate.hbm2ddl.auto" properties ("create", "update" or "create-drop") are working.
Any insight will be appreciated. Thanks in advance! :-)
Hibernate version: 3.2.4.sp1
Hibernate Annotations version: 3.3.0.ga
Mapping documents: JPA annotated class, no hibernate specific mappings or XML configuration files.
Code between sessionFactory.openSession() and session.close():
Code:
Session session = new AnnotationConfiguration()
.addAnnotatedClass(UserInfoType.class)
.setProperty(Environment.HBM2DDL_AUTO, "create")
.setProperty(Environment.POOL_SIZE, "1")
.setProperty(Environment.SHOW_SQL, "true")
.setProperty(Environment.FORMAT_SQL, "true")
.setProperty(Environment.AUTOCOMMIT, "false")
.setProperty(Environment.URL, "jdbc:mysql://localhost:3306/test")
.setProperty(Environment.USER, "root")
.setProperty(Environment.PASS, "secret")
.setProperty(Environment.DRIVER, com.mysql.jdbc.Driver.class.getName())
.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQL5InnoDBDialect
.class.getName())
.buildSessionFactory().openSession();
session.createCriteria(UserInfoType.class).list();
session.close();
Full stack trace of any exception that occurs:Code:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at Test.testAnnotationConfiguration(MD5Test.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'test.user' doesn't exist
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3249)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1268)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1403)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 25 more
Name and version of the database you are using:MySQL 5.0.37 (tested also with HSQLDB 1.8.0.7)
The generated SQL (show_sql=true):Code:
Hibernate:
insert
into
USER
(EMAIL, FIRST_NAME, LANGUAGE, LAST_NAME, PASSWORD, USERNAME, ACTIVATED, LAST_LOGIN, LAST_UPDATED)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.016 sec <<< FAILURE!
Debug level Hibernate log excerpt: