I've tried migrating from 2.0.3 to 2.1.2 and have been having a few problems. The most pressing one at the moment is the fact that 2.1.2 seems to not be detecting objects in a set that needs to be deleted before it can (re)insert them.
I have two objects, Genes and Submissions. A gene can be associated with multiple Sumissions. When one gene is loaded, there is only one Submission associated with it. I then add a Submission to the Gene, call commit, and get a PK exception because the association already exists.
Here's the code:
Code:
Gene gene = (Gene)session.load(DbGene.class, "PA303");
Submission foo = (Submission)session.load(DbSubmission.class, "PS203873");
gene.addSubmissionRecord(foo);
session.commit();
Here's my mapping (minus unrelated properties):
Code:
<class name="org.pharmgen.db.DbAccessionObject" table="PharmGKBObjectsView">
<id name="accessionId" column="pharmgkbAccessionId" type="string" unsaved-value="null">
<generator class="org.pharmgen.db.services.AccessionIdGenerator" />
</id>
<version name="version" column="version" />
<property name="name" />
<set name="submissionRecords" table="ObjectSubmissionAssociations" inverse="true" sort="natural" lazy="true" cascade="none">
<key column="pharmgkbAccessionId" />
<many-to-many column="submissionId" class="org.pharmgen.db.DbSubmission" />
</set>
<joined-subclass name="org.pharmgen.db.DbGene" table="Genes">
<key column="geneId" />
<property name="chromosome" column="chromosome" />
<property name="symbol" column="geneSymbol" />
</joined-subclass>
</class>
<class name="org.pharmgen.db.DbSubmission" table="Submissions">
<id name="submissionId" column="submissionId" type="string" unsaved-value="null">
<generator class="org.pharmgen.db.services.SubmissionIdGenerator" />
</id>
<set name="associatedAccessionObjects" table="ObjectSubmissionAssociations" sort="natural" lazy="true" cascade="none">
<key column="submissionId" />
<many-to-many column="pharmgkbAccessionId" class="org.pharmgen.db.DbAccessionIdentifier" />
</set>
</class>
Here's what I hope is the relevant section of the log:
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:567)] : Deleting rows of collection: [org.pharmgen.db.DbAccessionObject.submissionRecords#PA303]
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:567)] : Deleting rows of collection: [org.pharmgen.db.DbAccessionObject.submissionRecords#PA303]
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:592)] : no rows to delete
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:592)] : no rows to delete
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.updateRows(AbstractCollectionPersister.java:732)] : Updating rows of collection: org.pharmgen.db.DbAccessionObject.submissionRecords#PA303
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.updateRows(AbstractCollectionPersister.java:732)] : Updating rows of collection: org.pharmgen.db.DbAccessionObject.submissionRecords#PA303
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.updateRows(AbstractCollectionPersister.java:737)] : done updating rows: 0 updated
2004-02-09 19:28:39,663 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.updateRows(AbstractCollectionPersister.java:737)] : done updating rows: 0 updated
2004-02-09 19:28:39,673 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.insertRows(AbstractCollectionPersister.java:606)] : Inserting rows of collection: [org.pharmgen.db.DbAccessionObject.submissionRecords#PA303]
2004-02-09 19:28:39,673 DEBUG [net.sf.hibernate.collection.AbstractCollectionPersister.insertRows(AbstractCollectionPersister.java:606)] : Inserting rows of collection: [org.pharmgen.db.DbAccessionObject.submissionRecords#PA303]
2004-02-09 19:28:39,673 DEBUG [net.sf.hibernate.impl.BatcherImpl.logOpenPreparedStatement(BatcherImpl.java:196)] : about to open: 0 open PreparedStatements, 0 open ResultSets
2004-02-09 19:28:39,673 DEBUG [net.sf.hibernate.impl.BatcherImpl.logOpenPreparedStatement(BatcherImpl.java:196)] : about to open: 0 open PreparedStatements, 0 open ResultSets
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:237)] : insert into ObjectSubmissionAssociations (pharmgkbAccessionId, submissionId) values (?, ?)
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:237)] : insert into ObjectSubmissionAssociations (pharmgkbAccessionId, submissionId) values (?, ?)
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:241)] : preparing statement
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:241)] : preparing statement
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:46)] : binding 'PA303' to parameter: 1
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:46)] : binding 'PA303' to parameter: 1
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:46)] : binding 'PS100001' to parameter: 2
2004-02-09 19:28:39,683 DEBUG [net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:46)] : binding 'PS100001' to parameter: 2
2004-02-09 19:28:39,693 DEBUG [net.sf.hibernate.impl.BatcherImpl.logClosePreparedStatement(BatcherImpl.java:203)] : done closing: 0 open PreparedStatements, 0 open ResultSets
2004-02-09 19:28:39,693 DEBUG [net.sf.hibernate.impl.BatcherImpl.logClosePreparedStatement(BatcherImpl.java:203)] : done closing: 0 open PreparedStatements, 0 open ResultSets
2004-02-09 19:28:39,693 DEBUG [net.sf.hibernate.impl.BatcherImpl.closePreparedStatement(BatcherImpl.java:261)] : closing statement
2004-02-09 19:28:39,693 DEBUG [net.sf.hibernate.impl.BatcherImpl.closePreparedStatement(BatcherImpl.java:261)] : closing statement
2004-02-09 19:28:39,703 DEBUG [net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:36)] : SQL Exception
java.sql.SQLException: ORA-00001: unique constraint (PREVIEW.OBJECTSUBMISSIONS_PK) violated
This same piece of code works if I drop back to 2.0.3. Any ideas what might be causing this?
Thanks,
-Mark