Index: topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.34 topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.35 --- topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.34 Mon Sep 25 13:20:57 2006 +++ topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java Wed Sep 27 16:06:34 2006 @@ -23,9 +23,9 @@ * * @author poussin * - * @version $Revision: 1.34 $ + * @version $Revision: 1.35 $ * - * Last update: $Date: 2006/09/25 13:20:57 $ by : $Author: ruchaud $ + * Last update: $Date: 2006/09/27 16:06:34 $ by : $Author: bpoussin $ */ package org.codelutin.topia.framework; @@ -652,8 +652,13 @@ // on ne synchronise jamais les données avec la base tant que // l'utilisateur n'a pas fait de commit du context result.hibernate.setFlushMode(FlushMode.NEVER); - -// result.tx = result.hibernate.beginTransaction(); + + // 20060926 poussin ajouter pour voir si ca regle les problemes de deadlock h2 + // Conclusion, il faut bien ouvrir une transaction maintenant, sinon + // lorsque l'on fait des acces a la base, une transaction par defaut est + // utilisé mais elle n'est jamais vraiment fermé ce qui pose des problemes + // de lock sur les tables. + result.hibernate.beginTransaction(); return result; } @@ -675,16 +680,18 @@ for (TopiaDAO dao : daoCache.values()) { dao.commitTransaction(); } - Transaction tx = hibernate.beginTransaction(); + Transaction tx = hibernate.getTransaction(); +// Transaction tx = hibernate.beginTransaction(); hibernate.flush(); tx.commit(); + hibernate.beginTransaction(); // it's seem necessary to change session after commit // NON, NON, NON, il ne faut surtout pas le faire, ca pose plein de probleme // hibernate = getHibernateFactory().openSession(); // hibernate.setFlushMode(FlushMode.NEVER); fireOnCommited(); - } catch (HibernateException eee) { - throw new TopiaException(eee); + } catch (Exception eee) { + throw new TopiaException("Error during commit", eee); } } @@ -703,13 +710,18 @@ for (TopiaDAO dao : daoCache.values()) { dao.rollbackTransaction(); } - Transaction tx = hibernate.beginTransaction(); + Transaction tx = hibernate.getTransaction(); +// Transaction tx = hibernate.beginTransaction(); hibernate.clear(); tx.rollback(); + hibernate.close(); // it's very important to change the session after rollback // otherwize there are many error during next Entity's modification hibernate = getHibernateFactory().openSession(); hibernate.setFlushMode(FlushMode.NEVER); + + hibernate.beginTransaction(); + fireOnRollbacked(); } catch (HibernateException eee) { throw new TopiaException(eee); @@ -717,17 +729,20 @@ } public void closeContext() throws TopiaException { - if (getRootContext() == this) { - throw new TopiaException( - "Vous ne pouvez pas fermer le root context"); - } + // 20060926 poussin: Si si on peut, ca ferme en fait tous les enfants et c tout +// if (getRootContext() == this) { +// throw new TopiaException( +// "Vous ne pouvez pas fermer le root context"); +// } checkClosed("Ce contexte a deja ete ferme"); - this.closed = true; for(TopiaContextImplementor child : childContext.keySet()) { child.closeContext(); } - hibernate.close(); - getParentContext().removeChildContext(this); + if (getRootContext() != this) { + this.closed = true; + hibernate.close(); + getParentContext().removeChildContext(this); + } } public boolean isClosed() {