Index: topia/src/java/org/codelutin/topia/persistence/PersistenceStorageJDBC.java diff -u topia/src/java/org/codelutin/topia/persistence/PersistenceStorageJDBC.java:1.17 topia/src/java/org/codelutin/topia/persistence/PersistenceStorageJDBC.java:1.18 --- topia/src/java/org/codelutin/topia/persistence/PersistenceStorageJDBC.java:1.17 Thu Aug 11 16:40:14 2005 +++ topia/src/java/org/codelutin/topia/persistence/PersistenceStorageJDBC.java Fri Aug 12 16:20:01 2005 @@ -23,9 +23,9 @@ * Created: 20 juillet 2005 15:25:06 CEST * * @author Benjamin POUSSIN - * @version $Revision: 1.17 $ + * @version $Revision: 1.18 $ * - * Last update: $Date: 2005/08/11 16:40:14 $ + * Last update: $Date: 2005/08/12 16:20:01 $ * by : $Author: thimel $ */ @@ -60,6 +60,7 @@ import org.codelutin.queryparser.QueryHelperException; import org.codelutin.topia.TopiaConst; import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaEntity; import org.codelutin.topia.TopiaException; import org.codelutin.topia.TopiaId; import org.codelutin.topia.TopiaQuery; @@ -793,13 +794,17 @@ */ public void commitTransaction(TopiaContext context) throws TopiaPersistenceException { try{ + TopiaTransaction actualtt = context.getTransaction(); TopiaTransaction newtt = context.getTransaction().regenerateTransaction(); + // peut-etre faire quelque chose comme dans beginTransaction ? + // Comme on a fait un regenerateTransaction, le parent a deja pris en compte le changement de transaction, alors il faut impérativement le valider (au cas où une erreur survienne) + context.setTransaction(newtt); Connection conn = getConnection(); try{ PreparedStatement sta = conn.prepareStatement(SQL.getProperty(SQL_COMMIT_MANAGEMENT)); try{ sta.setLong(1, newtt.getCommitId()); - sta.setLong(2, context.getTransaction().getId()); + sta.setLong(2, actualtt.getId()); sta.execute(); } finally { sta.close(); @@ -810,7 +815,7 @@ sta = conn.prepareStatement(SQL.getProperty(SQL_COMMIT_DATA)); try{ sta.setLong(1, newtt.getCommitId()); - sta.setLong(2, context.getTransaction().getId()); + sta.setLong(2, actualtt.getId()); sta.execute(); } finally { sta.close(); @@ -821,8 +826,6 @@ conn.close(); } } - // peut-etre faire quelque chose comme dans beginTransaction ? - context.setTransaction(newtt); } catch(SQLException eee){ throw new TopiaPersistenceException("Erreur durant le commit transaction: " + context.getTransaction().getId(), eee); @@ -899,7 +902,16 @@ try{ int i = 1; for (Object o : queryHelper.getArgs()) { - sta.setObject(i, o); + if(o instanceof TopiaEntity){ + try { + sta.setObject(i, ((TopiaEntity)o).get_topiaId_()); + } catch (TopiaException eee) { + log.log(Level.SEVERE, o + " is a TopiaEntity but has no method called get_topiaId_()"); + sta.setObject(i, o); + } + }else{ + sta.setObject(i, o); + } i++; } ResultSet rr = sta.executeQuery();