[Biojava-l] Hibernate Exception when persisting some richsequence object to biosql schema

Deepak Sheoran sheoran143 at gmail.com
Sun Jan 24 21:20:03 UTC 2010


Hi,
I was trying to load the bct(bacteria) nucleotide genbank record from 
NCBI to my own instance of biosql and I got an hibernate exception(see 
it at the end of email):
The record which i tried to load is : LOCUS       AL596172              
248050 bp    DNA     linear   BCT 16-APR-2005
I don't why I am getting this error because I am not doing any 
manipulation to richSequence object I am simply reading it from file and 
trying to load it to database.The part of program which is responsible 
for loading the sequence is below:

while (seqs.hasNext()) {
                try {
                     richSequence = seqs.nextRichSequence();
                    // hibernate work begins
                    // start a transaction session
                    tx = session.beginTransaction();
                    // if got exception go to proper exception catch
                    session.save("Sequence", richSequence);
                    tx.commit();
                    successFullRecord++;  // one more record 
successfully added to database
                    session.clear();    // clear out the resources
                    session.flush();   // force memory cache to go to 
hardisk
                    RichObjectFactory.clearLRUCache(); // clear out LRU 
cache
                    System.out.println("Changes committed.  Records 
added: " + successFullRecord);
                    richSequence = null;  // clear out the memory 
references to richsequence
                } catch (HibernateException he) {
                    hibernateException++; // update the error count
                    he.printStackTrace();
                    richSequence = null; // reset the newRichSequence
                    tx.rollback();   // undo the changes before the 
error occured
                    session.clear(); // clear out the session
                    session.flush(); // force the session cache to hard disk
                    RichObjectFactory.clearLRUCache(); // clear out the 
LRU cache
                } catch (BioException ex) {
                    bioJavaException++;  // update the biojavaException 
error count
                    RichObjectFactory.clearLRUCache();
                    session.clear();
                    session.flush();
                    RichObjectFactory.clearLRUCache();
                    richSequence = null;
                } catch (Exception ex) {
                    otherException++; // update the otherError count
                    richSequence = null;
                    tx.rollback();  // rollBack the changes
                    //TODO make this to logger
                    System.out.println("Got general exception: " + 
ex.getLocalizedMessage());
                    ex.printStackTrace();
                    session.clear();
                    session.flush();
                    RichObjectFactory.clearLRUCache();
                    richSequence = null;
                }
            }

Please help I am really stuck on this issue.
Thanks
Deepak Sheoran
sheoran143 at gmail.com



_*Exception:*_
Jan 24, 2010 2:59:21 PM org.hibernate.jdbc.BatchingBatcher doExecuteBatch
SEVERE: Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row 
count from update [1]; actual row count: 0; expected: 1
       at 
org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61) 

       at 
org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46) 

       at 
org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
       at 
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
       at 
org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:34)
       at 
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247) 

       at 
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660) 

       at 
org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
       at 
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
       at 
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at 
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) 

       at 
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) 

       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
       at 
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at 
trashtesting.GenBankLoaderTesting.main(GenBankLoaderTesting.java:79)
Jan 24, 2010 2:59:21 PM 
org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row 
count from update [1]; actual row count: 0; expected: 1
       at 
org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61) 

       at 
org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46) 

       at 
org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
       at 
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
       at 
org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:34)
       at 
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247) 

       at 
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660) 

       at 
org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
       at 
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
       at 
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at 
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) 

       at 
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) 

       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
       at 
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at 
trashtesting.GenBankLoaderTesting.main(GenBankLoaderTesting.java:79)



More information about the Biojava-l mailing list