-->
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: Spring/Hibernate/HSQLDB session not saving to database
PostPosted: Fri Aug 08, 2008 6:37 am 
Newbie

Joined: Tue Apr 29, 2008 6:31 am
Posts: 7
Ok, so this one is frankly odd as far as I'm concerned.

I have a simple java application that reads a load of xml files and then populates the database. The problem is that when saveOrUpdate is called, the database doesn't get populated properly - HSQLDB database log file is incomplete and looks corrupted as if the JVM terminated half way through the transaction commit.

I'm using Spring 2.0.8 with AOP transaction management which I've used before with no problem. Here's the code:

Code:

public void uploadFormsToDB() {
      Session session = sessionFactory.getCurrentSession();

      IFormMetaData ifmd = (IFormMetaData) session.createQuery("from IFormMetaData as ana where ana.name=:name").setString("name", "sja").uniqueResult();

      log.info("Files to be processed: " + files.size());

      for (String filePath : files) {
         try {
            log.info("Processing file: " + filePath);

            SJABean sja = new SJABean(); // The SJA to be populated
            sja.getForm().setTimezoneoffset(0L);

            handler.setSja(sja);
            handler.setFilePath(filePath);
            handler.setIfmd(ifmd);

            xmlReader.setContentHandler(handler);
            xmlReader.parse(filePath);

            session.saveOrUpdate(sja.getForm());
         } catch (Exception e) {
            log.warn("Processing interrupted. " + e.getMessage(), e);
         }
      }
      log.info("Form import save started");
   }


sja.getForm returns the object to be saved to the db, it is formatted correctly with all the various fields populated. SaveOrUpdate executes with no problem - at least there're no exceptions.

The transaction config for this method is within spring:

Code:

   <aop:config>
      <aop:pointcut id="importerMethods" expression="execution(* com.sms.iforms2.sjaimporter.ProcessForms.*(..))"/>
      <aop:advisor advice-ref="txAdviceimport" pointcut-ref="importerMethods"/>
   </aop:config>


   <tx:advice id="txAdviceimport" transaction-manager="txManager">
      <tx:attributes>
         <tx:method name="*" propagation="REQUIRED"/>
      </tx:attributes>
   </tx:advice>


with the above method within ProcessForms.

The really bizzare thing is that if i step through the code with the debugger, occasionally the database will be written out correctly! This is a single threaded application so unless Hibernate or the HSQLDB jdbc driver utilises Threads I don't see how this can happen....

The application terminates once this method is completed.

I would Really appreciate any pointers on this as I've never come across this behaviour before - used to usual Hibernate exceptions ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 7:43 am 
Newbie

Joined: Tue Apr 29, 2008 6:31 am
Posts: 7
Hmm...this code works fine with mysql leading me to believe it's a problem with hypersonic.....

Anyone have any similar experiences?


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.