Hello all! I'm having some trouble making hibernate co-operate with the auto_increment PK's i've set up with MySQL. It's the same error message as in
http://forum.hibernate.org/viewtopic.php?t=932807 this thread, but i've definitely already set the MySQLDialect. Any help that anyone can give as to what's causing this would be most appreciated.
(If i understand it correctly, it'd be a bad idea to explicitly declare the generator class to be "increment", as we'd like to scale to a cluster eventually.)
Thanks,
A
Hibernate version: 2.1.2
Mapping documents:
<class ...
<id name="id" type="long">
<generator class="native"/>
</id>
...
</class>
Full stack trace of any exception that occurs:[java] net.sf.hibernate.JDBCException: Could not save object
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:172)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:705)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[java] at org.apache.tools.ant.Task.perform(Task.java:364)
[java] at org.apache.tools.ant.Target.execute(Target.java:341)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
[java] Caused by: net.sf.hibernate.JDBCException: Could not save object
[java] at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:783)
[java] at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
[java] at AJTesting.TestDesignObjects.main(TestDesignObjects.java:71)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:193)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:130)
[java] ... 13 more
[java] Caused by: java.sql.SQLException: General error message from server: "Table '*******.hibernate_unique_key' doesn't exist"
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
[java] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
[java] at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
[java] at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
[java] at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
[java] at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
[java] at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765)
[java] ... 21 more
[java] --- Nested Exception ---
[java] net.sf.hibernate.JDBCException: Could not save object
[java] at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:783)
[java] at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
[java] at AJTesting.TestDesignObjects.main(TestDesignObjects.java:71)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:193)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:130)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:705)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[java] at org.apache.tools.ant.Task.perform(Task.java:364)
[java] at org.apache.tools.ant.Target.execute(Target.java:341)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
[java] Caused by: java.sql.SQLException: General error message from server: "Table '*******.hibernate_unique_key' doesn't exist"
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
[java] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
[java] at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
[java] at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
[java] at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
[java] at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
[java] at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765)
[java] ... 21 more
Name and version of the database you are using: MySQL 4.0.11a-gamma[/url]