Skip to content
Snippets Groups Projects
Commit ce6cd9ae authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #348 - delete database results in error

parent d6c6ab06
Branches
Tags
No related merge requests found
Pipeline #330 passed
...@@ -62,7 +62,10 @@ public class Tag ...@@ -62,7 +62,10 @@ public class Tag
@Override @Override
public String toString() public String toString()
{ {
return "Tag{ID=" + ID + ", name='" + name + '}'; return "Tag{" +
"ID=" + ID +
", name='" + name + '\'' +
'}';
} }
@Override @Override
...@@ -78,7 +81,6 @@ public class Tag ...@@ -78,7 +81,6 @@ public class Tag
@Override @Override
public int hashCode() public int hashCode()
{ {
return Objects.hash(ID, name); return Objects.hash(ID, name);
} }
} }
\ No newline at end of file
...@@ -111,6 +111,12 @@ public class TransactionService implements Resetable ...@@ -111,6 +111,12 @@ public class TransactionService implements Resetable
public void deleteTransaction(Integer ID) public void deleteTransaction(Integer ID)
{ {
if(isDeletable(ID)) if(isDeletable(ID))
{
deleteTransactionInRepo(ID);
}
}
private void deleteTransactionInRepo(Integer ID)
{ {
Transaction transactionToDelete = transactionRepository.findOne(ID); Transaction transactionToDelete = transactionRepository.findOne(ID);
// handle repeating transactions // handle repeating transactions
...@@ -123,7 +129,6 @@ public class TransactionService implements Resetable ...@@ -123,7 +129,6 @@ public class TransactionService implements Resetable
transactionRepository.delete(ID); transactionRepository.delete(ID);
} }
} }
}
public boolean isDeletable(Integer ID) public boolean isDeletable(Integer ID)
{ {
...@@ -134,7 +139,10 @@ public class TransactionService implements Resetable ...@@ -134,7 +139,10 @@ public class TransactionService implements Resetable
@Override @Override
public void deleteAll() public void deleteAll()
{ {
transactionRepository.deleteAll(); for(Transaction transaction : transactionRepository.findAll())
{
deleteTransactionInRepo(transaction.getID());
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment