-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem migrating from 2.0.3 to 2.1.2
PostPosted: Tue Feb 10, 2004 12:16 am 
Beginner
Beginner

Joined: Wed Oct 01, 2003 11:01 pm
Posts: 23
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2004 12:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Are all your equals/hashCode/compareTo implementations correct and consistent with each other?

What happens if you use an unsorted collection?

Quote:
not be detecting objects in a set that needs to be deleted before it can (re)insert them. .... When one gene is loaded, there is only one Submission associated with it. I then add a Submission to the Gene


What are you talking about?? Why should Hibernate delete a row just so that it can insert a different row??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.