Hello,
I'm trying to store the following class:
Code:
public class AlignJob {
private int id;
private String user,jobName;
private long totalCost;
private Container container;
...All needed setters, getters & constructors
}
Here the class
container looks like this:
Code:
public class Container {
private int maxFullMatches;
private List fullMatches;
...setters,getters & constructors...
}
As you can see it just has an integers, combined with a list of another self-made class:
Code:
public class FullMatch implements Match{
private int id;
private String sequenceName1,sequenceName2;
private int score;
...setters,getters & constructors...
}
The mapping for the class
FullMatch is quit simple:
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>
<class name="be.ugent.aligner.FullMatch" table="FullMATCH">
<id name="id" column="FULLMATCH_ID">
<generator class="increment"/>
</id>
<property name="sequenceName1"/>
<property name="sequenceName2"/>
<property name="score"/>
</class>
</hibernate-mapping>
The mapping for
AlignLib (=the upper-class) is a bit more complicated:
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>
<class name="be.ugent.aligner.server.AlignJob" table="INCOMPLETEJOBS"
entity-name="IncompleteAlignJob"
>
<id name="id" column="ALIGNJOB_ID" >
<generator class="increment"/>
</id>
<property name="user"/>
<property name="jobName"/>
<property name="totalCost"/>
<component name="container" class="be.ugent.aligner.Container">
<property name="maxFullMatches"/>
<list name="fullMatches" cascade="all">
<key column="ALIGNJOB_ID"/>
<index column="FULLMATCH_INDEX" />
<one-to-many class="be.ugent.aligner.FullMatch"/>
</list>
</component>
</class>
When I try to
store the AlignJob:
Code:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate("IncompleteAlignJob",job);
tx.commit();
session.close();
I get the following output:
Code:
Hibernate: select max(ALIGNJOB_ID) from INCOMPLETEJOBS
Hibernate: select max(FULLMATCH_ID) from FULLMATCH
Hibernate: insert into INCOMPLETEJOBS (user, jobName, totalCost, indexDatabase1, indexDatabase2, matrixName, open, extend, databaseName1, databaseName2, maxFullMatches, maxSimpleMatches, ALIGNJOB_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into FULLMATCH (sequenceName1, allignedSequence1, start1, sequenceName2, allignedSequence2, start2, identity, similarity, gaps, score, FULLMATCH_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into FULLMATCH (sequenceName1, allignedSequence1, start1, sequenceName2, allignedSequence2, start2, identity, similarity, gaps, score, FULLMATCH_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into FULLMATCH (sequenceName1, allignedSequence1, start1, sequenceName2, allignedSequence2, start2, identity, similarity, gaps, score, FULLMATCH_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into FULLMATCH (sequenceName1, allignedSequence1, start1, sequenceName2, allignedSequence2, start2, identity, similarity, gaps, score, FULLMATCH_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into FULLMATCH (sequenceName1, allignedSequence1, start1, sequenceName2, allignedSequence2, start2, identity, similarity, gaps, score, FULLMATCH_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update FULLMATCH set ALIGNJOB_ID=?, FULLMATCH_INDEX=? where FULLMATCH_ID=?
Hibernate: update FULLMATCH set ALIGNJOB_ID=?, FULLMATCH_INDEX=? where FULLMATCH_ID=?
Hibernate: update FULLMATCH set ALIGNJOB_ID=?, FULLMATCH_INDEX=? where FULLMATCH_ID=?
Hibernate: update FULLMATCH set ALIGNJOB_ID=?, FULLMATCH_INDEX=? where FULLMATCH_ID=?
Hibernate: update FULLMATCH set ALIGNJOB_ID=?, FULLMATCH_INDEX=? where FULLMATCH_ID=?
20:07:41,656 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
20:07:41,656 ERROR JDBCExceptionReporter:72 - failed batch
20:07:41,671 ERROR AbstractFlushingEventListener:299 - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at be.ugent.aligner.server.DBMS.SaveJob(DBMS.java:268)
at be.ugent.aligner.server.AlignJob.finishAlign(AlignJob.java:133)
at be.ugent.aligner.server.DBMS.main(DBMS.java:54)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 10 more
(the following is the real error as it is thrown)
Code:
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at be.ugent.aligner.server.DBMS.SaveJob(DBMS.java:268)
at be.ugent.aligner.server.AlignJob.finishAlign(AlignJob.java:133)
at be.ugent.aligner.server.DBMS.main(DBMS.java:54)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 10 more
If I don't let Hibernate map the List, everything works fine (so my AlignLib.hbm.xml looks then like this):
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>
<class name="be.ugent.aligner.server.AlignJob" table="INCOMPLETEJOBS"
entity-name="IncompleteAlignJob"
>
<id name="id" column="ALIGNJOB_ID" >
<generator class="increment"/>
</id>
<property name="user"/>
<property name="jobName"/>
<property name="totalCost"/>
<component name="container" class="be.ugent.aligner.Container">
<property name="maxFullMatches"/>
</component>
</class>
So I guess it's the list that's causing the exception...
Can anyone help me here???
I'm using the newest Hibernate stable build (version 3.1.3 I think), and as database I use HSQL (newest version, 1.8.0).
Tnx in advance,
Jeroen