diff --git a/.gitignore b/.gitignore index 7455e11..f07ce7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /releases /test-bin +/bin/ diff --git a/src/de/willuhn/datasource/db/AbstractDBObject.java b/src/de/willuhn/datasource/db/AbstractDBObject.java index 3f99291..1192ec0 100755 --- a/src/de/willuhn/datasource/db/AbstractDBObject.java +++ b/src/de/willuhn/datasource/db/AbstractDBObject.java @@ -217,7 +217,7 @@ private boolean inTransaction() { synchronized(transactions) { - Transaction t = (Transaction) getTransaction(); + Transaction t = getTransaction(); return (t != null && t.count > 0); } } @@ -672,11 +672,17 @@ public void insert() throws RemoteException, ApplicationException if (this.id == null) this.id = getLastId(); - if (!this.inTransaction()) - getConnection().commit(); + boolean tx = this.inTransaction(); + this.created = tx; // Rollback-Markierung nur setzen, wenn wir in einer Transaktion sind + + // Sonst auto-commit + if (!tx) + { + getConnection().commit(); + } notify(storeListeners); - this.created = true; + } catch (SQLException e) { @@ -1249,6 +1255,10 @@ public final void transactionCommit() throws RemoteException try { Logger.debug("[commit] transaction commit"); getConnection().commit(); + + // Transaktion ist durch. Egal, ob das Ojekt gerade erstellt wurde oder + // schon existierte. Jetzt ist es auf jeden Fall nicht mehr frisch. + this.created = false; } catch (SQLException se) {