Index: topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.13 topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.14 --- topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.13 Fri Feb 10 14:01:25 2006 +++ topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java Thu Feb 23 14:05:47 2006 @@ -23,9 +23,9 @@ * * @author poussin * - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * - * Last update: $Date: 2006/02/10 14:01:25 $ by : $Author: bpoussin $ + * Last update: $Date: 2006/02/23 14:05:47 $ by : $Author: bpoussin $ */ package org.codelutin.topia.framework; @@ -54,6 +54,7 @@ import org.codelutin.topia.event.TopiaEntityLoadEvent; import org.codelutin.topia.event.TopiaEntityLoadListener; import org.codelutin.topia.event.TopiaTransactionEvent; +import org.codelutin.topia.event.TopiaTransactionEvents; import org.codelutin.topia.event.TopiaTransactionListener; import org.codelutin.topia.event.TopiaVetoableEntityEvent; import org.codelutin.topia.event.TopiaVetoableEntityListener; @@ -90,6 +91,7 @@ import org.hibernate.event.PreUpdateEvent; import org.hibernate.event.PreUpdateEventListener; import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.hibernate.tool.hbm2ddl.SchemaUpdate; /** * Le TopiaContextImpl est le point d'entre pour acceder aux donnees. Il est @@ -253,6 +255,21 @@ } } + /* (non-Javadoc) + * @see org.codelutin.topia.TopiaContext#createSchema() + */ + public void updateSchema() throws TopiaException { + try { + boolean showSchema = false; + if (log.isDebugEnabled()) { + showSchema = true; + } + new SchemaUpdate(getHibernateConfiguration()).execute(showSchema, true); + } catch (HibernateException eee) { + throw new TopiaException("Can't create database schema", eee); + } + } + /* * (non-Javadoc) * @@ -631,6 +648,9 @@ Transaction tx = hibernate.beginTransaction(); hibernate.clear(); tx.rollback(); + // it's very important to change the session after rollback + // otherwize there are many error during next Entity's modification + hibernate = getHibernateFactory().openSession(); fireOnRollbacked(); } catch (HibernateException eee) { throw new TopiaException(eee); @@ -921,8 +941,12 @@ } try { for(Iterator l=getTransactionListeners().iterator(); l.hasNext();) { - l.next().commit(transactionEvents); + l.next().commit(new TopiaTransactionEvents(this, transactionEvents)); } + // poussin FIXME: il faut bien prevenir notre pere, mais je ne pense + // pas que ce soit le bon moyen. Je pense qu'il faut une methode + // specifique pour cela, sans doute le pere peut-il etre listener + // sur le fils ? if (getParentContext() != null) { getParentContext().fireOnCommited(); } @@ -943,8 +967,13 @@ log.info("onRollbacked"); } try { + TopiaTransactionEvents e = null; for(Iterator l=getTransactionListeners().iterator(); l.hasNext();) { - l.next().rollback(transactionEvents); + // on cree l'event que si on en a besoin + if (e == null) { + e = new TopiaTransactionEvents(this, transactionEvents); + } + l.next().rollback(e); } } catch (Exception eee) { if (log.isWarnEnabled()) {