-->
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.  [ 4 posts ] 
Author Message
 Post subject: Data not written into DB
PostPosted: Fri Nov 02, 2007 6:54 pm 
Newbie

Joined: Fri Oct 21, 2005 4:31 am
Posts: 8
Location: Bern / Switzerland
Hi all

I'm having trouble with permanent data persistence. Inside a process I am able to successfully CRUD entities into my hsql DB. The data is there and I have access to it by finder methods (checked). But once the application is shut down there is no data written to the DB file (checked with Eclipse Database Explorer). HSQL is configured correctly, table type is cached.

Hibernate Version 3.2 with Annotaions and EntityManager.

persistence.xml
Code:
<persistence-unit name="myPU" transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <class>my.class</class>
  <properties>
    <property name="hibernate.connection.driver_class"
      value="org.hsqldb.jdbcDriver" />
    <property name="hibernate.connection.url"
      value="jdbc:hsqldb:file:/db/mydb;shutdown=true" />
    <property name="hibernate.connection.username" value="sa" />
    <property name="hibernate.dialect"
      value="org.hibernate.dialect.HSQLDialect"/>
  </properties>
</persistence-unit>


I'm using a MyEclipse generated EntityManagerHelper class and this is the persist call:

Code:
EntityManagerHelper.beginTransaction();
EntityManagerHelper.getEntityManager().persist(entity);
EntityManagerHelper.commit();


What am I doing wrong? I'm stuck :(

Thanks very much in advance!

Simon


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 5:25 am 
Newbie

Joined: Fri Oct 21, 2005 4:31 am
Posts: 8
Location: Bern / Switzerland
Hi

Is this probabely a hibernate bug? I have changed the connection parameters and HSQL now runs in Server mode instead of Standalone mode:

before:
Code:
<property name="hibernate.connection.url"
  value="jdbc:hsqldb:file:/db/mydb;shutdown=true" />


now:
Code:
<property name="hibernate.connection.url"
  value="jdbc:hsqldb:hsql://localhost/mydb;shutdown=true" />


This works fine. Hibernate is able to create the database and insert queries are stored permanently inside the db files.

I could need some help on this one :(

Regards
Simon


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 9:17 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:20 am
Posts: 74
it's just the way hSQL works (or doesn't).
The old way was fine with old versions of hSQL but they changed something a while ago (last year or 2005 I think) and now shutdown no longer persists data unless you explicitly call for it first.
Most tutorials however are still based on the old version.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 9:28 am 
Newbie

Joined: Fri Oct 21, 2005 4:31 am
Posts: 8
Location: Bern / Switzerland
Hello jwenting

Could you point me to a resource where this is explained? Or do you know a workaround to get it working?

Regards
Simon


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.