Skip to content

Commit

Permalink
Transaction-Flag hatte einen falschen Wert, wenn ein gerade (und auss…
Browse files Browse the repository at this point in the history
…erhalb einer Transaktion) erstelltes Objekt anschliessend innerhalb einer Transaktion verwendet und diese zurueckgerollt wurde. Da das Objekt ja ausserhalb der Transaktion erzeugt wurde, existiert es und darf nicht zurueckgerollt werden.
  • Loading branch information
willuhn committed Jan 16, 2015
1 parent d7b81c8 commit 2365a21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
/releases
/test-bin
/bin/
18 changes: 14 additions & 4 deletions src/de/willuhn/datasource/db/AbstractDBObject.java
Expand Up @@ -217,7 +217,7 @@ private boolean inTransaction()
{
synchronized(transactions)
{
Transaction t = (Transaction) getTransaction();
Transaction t = getTransaction();
return (t != null && t.count > 0);
}
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 2365a21

Please sign in to comment.