Spring Boot + JPA : @Transactional annotation : Roll back is not working

Naveen Yalla :

I am using @Transactional with spring boot and jpa. But it is not working. Can somebody help out.

My inserts are in myDAO which is autowired in service class. Below code is method of service class which is implementing service interface

class MyService implements Service {

@Transactional(rollbackFor = RuntimeException.class)
    public ResponseVO createOrder(params) {
    myDAO.insertInTable1(param);
    myDAO.insertInTable2(param);//I kept wrong table name in this query such that it throws exception
         }

 }
Naveen Yalla :

Issue is with MySQL Database engine. My engine was MYIsam which doesn't supports Transactions. I changed my DB engine to InnoDB and its working. Thanks for the contributions. Below are the queries for the same.

SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_NAME = 'tabel_name' AND TABLE_SCHEMA='db_name';

ALTER TABLE table_name ENGINE = INNODB;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=115475&siteId=1