The following exception occured when i execute my code.
Code:
Hibernate: insert into SEMINAR (title, description, MEMBER_ID) values (?, ?, ?)
Hibernate: SELECT LAST_INSERT_ID()
Hibernate: update SEMINAR set title=?, description=?, MEMBER_ID=? where SEMINAR_ID=?
Hibernate: insert into SEMINARTOPIC (title, description, data) values (?, ?, ?)
Hibernate: SELECT LAST_INSERT_ID()
Hibernate: update SEMINARTOPIC set title=?, description=?, data=? where SEMINARTOPIC_ID=?
Hibernate: insert into SEMINARTOPIC (title, description, data) values (?, ?, ?)
Hibernate: SELECT LAST_INSERT_ID()
Hibernate: update SEMINARTOPIC set title=?, description=?, data=? where SEMINARTOPIC_ID=?
Hibernate: update PERSON set SEMINAR_ID=?, I=? where PERSON_ID=?
Could not synchronize database state with session
net.sf.hibernate.HibernateException: Batch update row count wrong: 0
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:65)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:118)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2306)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2260)
The Code, that is executed, is the following:
Code:
// insert seminar
Seminar seminar = new Seminar();
seminar.setDescription("One2ManyUniTest");
session.saveOrUpdate(seminar);
// insert seminar topics
SeminarTopic st1 = new SeminarTopic();
st1.setTitle("testTopic1");
session.saveOrUpdate(st1);
SeminarTopic st2 = new SeminarTopic();
st2.setTitle("testTopic2");
session.saveOrUpdate(st2);
// add seminar topics to seminar
ArrayList sts = new ArrayList();
sts.add(st1);
sts.add(st2);
seminar.setSeminarTopics(sts);
session.saveOrUpdate(seminar);
The mapping is the following:
Code:
- <class name="model.Person" select-before-update="true" table="PERSON" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" optimistic-lock="version">
.....
- <subclass name="model.SeminarParticipant" extends="model.Person" dynamic-update="false" dynamic-insert="false">
- <property name="department" not-null="false" unique="false" update="true" insert="true">
<column name="department" not-null="false" />
</property>
- <property name="email" not-null="false" unique="false" update="true" insert="true">
<column name="email" not-null="false" />
</property>
<many-to-one name="seminarTopic" column="SEMINARTOPIC_ID" insert="false" update="false" not-null="false" unique="false" outer-join="auto" />
<many-to-one name="seminar" column="SEMINAR_ID" insert="false" update="false" not-null="false" unique="false" outer-join="auto" />
- <property name="matriculationNo" not-null="false" unique="false" update="true" insert="true">
<column name="matriculationNo" not-null="false" />
</property>
</subclass>
....
</class>
- <class name="model.Seminar" table="SEMINAR" select-before-update="true" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" optimistic-lock="version">
.....
- <list name="seminarTopics" lazy="true" cascade="save-update" inverse="false" batch-size="1" outer-join="auto">
<index column="I" />
<key column="SEMINAR_ID" />
<one-to-many class="model.SeminarTopic" />
</list>
- <list name="seminarParticipants" lazy="true" cascade="save-update" inverse="false" batch-size="1" outer-join="auto">
<index column="I" />
<key column="SEMINAR_ID" />
<one-to-many class="model.SeminarParticipant" />
</list>
......
</class>
- <class name="model.SeminarTopic" table="SEMINARTOPIC" select-before-update="true" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" optimistic-lock="version">
...
- <list name="seminarParticipants" lazy="true" cascade="save-update" inverse="false" batch-size="1" outer-join="auto">
<index column="I" />
<key column="SEMINARTOPIC_ID" />
<one-to-many class="model.SeminarParticipant" />
</list>
...
</class>
The error occurec when hibernate tried to update the table person. there is no datasets in it. therefore i become the exception: Batch update row count wrong: 0. But i don't know how i set the configuration so that no update in the table person will be executed.
thanks in advance