Hi @ all,
I i've got a problem! I modelled a DB with Question (table) and their option(s) (table). The tables should have a 0..* relation, meaning one question can have zero or more options, but one option belongs to only one question.
There for I created two mapping files:
question.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="core">
<class name="Question" table="Frage">
<id name="id" column="ID">
<generator class="increment"></generator>
</id>
<property name="question" column="Frage"></property>
<property name="answerClass" column="AntwortKlasse"></property>
<property name="evaluationClass" column="AuswertungsKlasse"></property>
<property name="obligation" column="Pflicht"></property>
<property name="time" column="Zeit"></property>
<property name="order" column="Reihenfolge"></property>
<property name="hint" column="Hinweis"></property>
<property name="groupID" column="GruppenID"></property>
<set name="options" lazy="false" cascade="all">
<key column="FrageID"></key>
<one-to-many class="Option"></one-to-many>
</set>
</class>
</hibernate-mapping>
option.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="core">
<class name="Option" table="Option">
<id name="id" column="ID">
<generator class="increment"></generator>
</id>
<property name="code" column="Code"></property>
<property name="option" column="Option"></property>
<property name="questionID" column="FrageID"></property>
</class>
</hibernate-mapping>
I did not forget to include these files in the hibernate.hbm.xml!
So the Problem is this exception, when I want to store my question object:
WARN - JDBCExceptionReporter - SQL Error: 1064, SQLState: 42000
ERROR - JDBCExceptionReporter - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Option' at line 1
org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator
It would be sooo nice, if anyone could help me!!!!
With best regards
Andy