[BioSQL-l] [Biojava-l] Load/Update Genbank sequence issue

Doug Brown debrown at unity.ncsu.edu
Wed May 21 18:50:09 UTC 2008


Hi Gang wu,

  I recognize your problem. I to had to build a loader for genbank flat 
files. When attempting to 'replace' a record stored in the database, one 
needs to explicitly delete it before doing the save. I found that the 
hibernate code does not seem to understand that an in-memory deletion 
should be realized in the data base prior to the new insertion. My 
solution, see attached code, was to commit the transaction for the 
deletion and then open a new transaction for the insertion.

Try inserting the following after "System.out.println("Loaded sequence"":

        // delete any extant  sequence from the database. The cascaded
        // constraints will result in removal of all associated features
        // and what-not.
        Query q = session.createQuery( "from BioEntry as s where s.name 
= :acc");
        q.setString( "acc", sequence.getAccession());
        BioEntry be = (BioEntry)q.uniqueResult();
        if ( be != null)
          {
          // Interestingly, hibernate does not seem to do transactions 
in the
          // same sense that a database would. Thus, I need to commit the
          // delete operation before I attempt to insert the replacement
          // information.
          session.delete( be);
          tx.commit();
          tx = session.beginTransaction();
          }


Regards,
Doug

gang wu wrote:
> I got another problem with almost the same code(see attached code and 
> output). If I call the loadSeq() only once, everything works fine. The 
> second call of the same method will fail. By the exception message, it 
> looks like the session is not cleaned up yet though at the end of the 
> method the session has been flush/clear/closed. Anything wrong?

-- 
Doug Brown - Bioinformatics
Fungal Genomics Laboratory
Center for Integrated Fungal Research
North Carolina State University
Campus Box 7251, Raleigh, NC 27695-7251
https://www.fungalgenomics.ncsu.edu/~debrown/
Tel: (919) 513-0394, Fax (919) 513-0024
e-mail: doug_brown AtSign ncsu.edu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: BriefLoader.java
Type: text/x-java
Size: 11672 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/biosql-l/attachments/20080521/e5cd70d1/attachment-0002.bin>


More information about the BioSQL-l mailing list