Play 2.8 Database Transaction RollBack

Hi ,

Im migrating application from play 2.2 to Play 2.8
Exsisting code has --> try {
}catch(PersistenceException e){
if(e.getCause() instanceof ConstraintViolationException) {



Question: How can this be handled in Play 2.8 , ```

Im making calls repository.savePC(pc);

In case of exception both transaction should get rolled back.

Thank you for the help

It seems that the withTransaction method takes care of the transaction. You don’t have to rollback or commit.

Also, why do you start another transaction after rolling back - do you execute something else after?

Thank you for the reply.

Yes after rolling back transaction ,I have to execute select

Line1: repository.savePC(pc);
Line 2: resositoryDs.saveDS(ds);

expecting to get both transaction rolled back in case of any exceptions
then execute repositoryDate.getLatestDate();

currently if any exception occurred at resositoryDs.saveDS(ds); --> this gets rollback but
Line 1 inserted record remains in DB.