Hey folks. I'm working through the Hello World app in the book and can't seem to get it to run, due to this error on the id of the Messages table.
Code:
mark@markUbuntu:~$ cd workspace/He*
mark@markUbuntu:~/workspace/HelloWorld$ ant run
Buildfile: build.xml
clean:
[delete] Deleting directory /home/mark/workspace/HelloWorld/bin
[mkdir] Created dir: /home/mark/workspace/HelloWorld/bin
compile:
[javac] Compiling 3 source files to /home/mark/workspace/HelloWorld/bin
copymetafiles:
[copy] Copying 3 files to /home/mark/workspace/HelloWorld/bin
run:
[java] 21:07:49,99021:07:49,99521:07:50,00021:07:50,00421:07:50,06621:07:50,06621:07:50,17321:07:50,30021:07:50,38521:07:50,39721:07:50,39821:07:50,39821:07:50,40621:07:50,40621:07:50,70221:07:50,70221:07:50,71821:07:50,72321:07:50,72521:07:50,72521:07:50,72521:07:50,72521:07:50,72521:07:50,72621:07:50,72621:07:50,72621:07:50,72721:07:50,72721:07:50,72721:07:50,72721:07:50,72721:07:50,72721:07:50,72921:07:50,72921:07:50,72921:07:50,72921:07:50,72921:07:50,72921:07:50,73021:07:50,73021:07:50,73521:07:50,73621:07:50,73621:07:50,73621:07:50,73621:07:50,78121:07:51,011Hibernate:
[java] select
[java] max(MESSAGE_ID)
[java] from
[java] MESSAGES
[java] Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator
[java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
[java] at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:131)
[java] at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:68)
[java] at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
[java] at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
[java] at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
[java] at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
[java] at hello.HelloWorld.main(Unknown Source)
[java] Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'HelloWorld.MESSAGES' doesn't exist
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[java] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[java] at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
[java] at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
[java] at com.mysql.jdbc.Util.getInstance(Util.java:381)
[java] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
[java] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
[java] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
[java] at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)
[java] at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1761)
[java] at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1912)
[java] at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:109)
[java] ... 11 more
[java] 21:07:51,11721:07:51,117
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 2 seconds
mark@markUbuntu:~/workspace/HelloWorld$
Hibernate version: 3
Mapping documents:Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="hello.Message"
table="MESSAGES">
<id
name="id"
column="MESSAGE_ID">
<generator class="increment"/>
</id>
<property
name="text"
column="MESSAGE_TEXT"/>
<many-to-one
name="nextMessage"
cascade="all"
column="NEXT_MESSAGE_ID"
foreign-key="FK_NEXT_MESSAGE"/>
</class>
</hibernate-mapping>
Name and version of the database you are using: MySQL 5.0
Any help would be appreciated!
Mark