-->
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: Datensätze fehlen; Transaction-commit verzögert
PostPosted: Sun Nov 25, 2007 10:15 am 
Newbie

Joined: Sun Nov 25, 2007 10:03 am
Posts: 1
Hi!

Ich habe ein Problem mit Hibernate und zwar werden nicht alle Datensätze in einer HSQLDB gespeichert. Im konkreten Fall nur 96 statt 100.

Das Problem liegt anscheined, dass zwischen dem commit einer Transaction und dem close() der Session ein paar Sekunden vergehen müssen.
Auch ein flush() ändert nichts am Verhalten.
Erst dann werden die letzten Datensätze geschrieben.
Kann man so einen Timeout konfigurieren oder liegt das Problem wo anders?

Bin für jeden Tipp dankbar.

Michl

Code:
import java.io.IOException;
import java.util.Calendar;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;


public class TestWorkingTime {

   public static void main(String[] args) {
      AnnotationConfiguration configuration = new AnnotationConfiguration();
      configuration.configure();
      SessionFactory sessionFactory = configuration.buildSessionFactory();
      Session session = sessionFactory.openSession();
      Transaction transaction = session.beginTransaction();
      for (int i=0; i<100; i++) {
         WorkingTime wt = new WorkingTime();
         wt.setDate(Calendar.getInstance().getTime());
         session.save(wt);
      }
      try {
         transaction.commit();
         System.in.read();
         session.close();
         sessionFactory.close();
      } catch (IOException e) {
         e.printStackTrace();
      }
   }

}

Meine hibernate-Config:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="connection.url">jdbc:hsqldb:file:myhibdb</property>
        <property name="connection.username">sa</property>
        <property name="connection.password"></property>
       
        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create</property>
       
        <property name="hibernate.format_sql">true</property>
       
        <!-- Auflistung der gemappten Klassen -->
        <mapping class="WorkingTime"/>
   

    </session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 23, 2007 5:57 am 
Beginner
Beginner

Joined: Tue Oct 26, 2004 8:14 am
Posts: 20
Location: Mainz, Germany
Hi,

klingt ja merkwürdig. Probier doch mal zum Testen, den Flush in die Schleife zu packen. Fehlen denn die letzten Einträge oder mittendrin welche ?


Gruss,
Matthias


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.