-->
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: [resolu][transaction] Enregistrements supprimés arret AS
PostPosted: Fri Jan 12, 2007 1:39 pm 
Newbie

Joined: Fri Jan 12, 2007 12:24 pm
Posts: 5
Location: Geneva, Switzerland
Bonsoir tous le monde,

J'ai un problème que je n'arrive pas à résoudre.

J'ai une application fonctionnant sous Spring et Hibernate intégrée à un serveur d'application JBoss.

Pour une requête j'ai un traitement qui ajoute un nouvel enregistrement à un table. Là tout marche correctement. Chaque requête génère bien un enregistrement.

Par contre lorsque je stoppe mon serveur d'application, tous les enregistrements crées précédements sont supprimés. (C'est bête)

Je pense que celà doit venir de la gestion des transactions, mais j'ai tout essayé en vain.

Si quelqu'un à un idée c'est bien volontiers.

D'avance merci et bonne soirée.

Soraya.

P.S Si je n'utilise pas Spring, je n'ai pas ce problème.


Hibernate version: 3.2
Spring version: 2.0.1
Name and version of the database : DB400 for iSeries

Code qui ajoute l'enregistrement

Code:
   public User create(String id, String name) {

   Session session = this.sessionFactory.openSession();

   UserTransaction tx;

   try {
      
       tx = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");

       tx.begin();

       User user = new User();

       user.setId(id);
       user.setName(name);

       session.save(user);
       session.flush();

       tx.commit();
      
       session.close();

       return user;

   } catch (Exception e) {
       e.printStackTrace();
       return null;
   }

   
    }


Configuration Hibernate
Code:
<hibernate-configuration>

   <session-factory>
      <property name="connection.url">jdbc:as400://192.168.10.106;extended dynamic=true;package=jbpkg;package cache=true;package library=jboss;errors=full</property>
      <property name="connection.username">XXX</property>
      <property name="connection.password">XXX</property>
      <property name="connection.driver_class">com.ibm.as400.access.AS400JDBCDriver</property>
      <property name="connection.pool_size">1</property>

      <property name="dialect">org.hibernate.dialect.DB2400Dialect</property>

      <property name="hibernate.current_session_context_class">jta</property>
      <property name="hibernate.transaction.manager_lookup_class">
         org.hibernate.transaction.JBossTransactionManagerLookup
      </property>
      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
      <property name="hibernate.show_sql">true</property>


      <mapping resource="ch/isys/best/User.hbm.xml" />


   </session-factory>

</hibernate-configuration>




Fichier de mapping
Code:
<hibernate-mapping>
   <class name="ch.isys.best.User" table="USER" schema="WRKJMTJAVA" catalog="S657E7ED">
      <id name="id" column="ruser">
      </id>
      <property name="name" column="rname"></property>
      <property name="service" column="rserv"></property>
   </class>
</hibernate-mapping>


Fichier de mapping
Code:
<beans>
   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
   </bean>
   <bean id="userDao" class="ch.isys.best.core.security.dao.manager.UserDaoImpl">
      <property name="sessionFactory" ref="sessionFactory"></property>
   </bean>
</beans>


Last edited by Soraya on Tue Jan 23, 2007 4:01 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 14, 2007 3:56 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Jette un oeil aux logs de org.hibernate.transaction. Vérifie particulièrement les logs affichés lors de ton begin et de ton commit. Es tu sûr d'ailleurs que ton code ne lance pas d'exception ? À ta place, j'enleverais le try/catch pour éviter qu'un problème passe inaperçu. Ce n'est de toute façon jamais bon de faire simplement un printStackTrace() lorsqu'une exception est levée.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.