Spring atomicity Jdbc with alternative table

I am trying to write the equivalent of the evolution / rollback mechanism of a Rails data model using Spring Jdbc.

Spring Jdbc transactionnal insert/replaceworks very well (DataSourceTransactionManager with PROPAGATION_REQUIRED in InnoDB mysql 5):

// Transaction begins
getJdbcTemplate().execute("replace into aTable ...");
getJdbcTemplate().execute("wrong request");
getJdbcTemplate().execute("replace into aTable ...");
// none are commited

but alternot:

// Transaction begins
getJdbcTemplate().execute("alter table aTable add column `columnForTest` ...");
getJdbcTemplate().execute("wrong request");
getJdbcTemplate().execute("alter table aTable add column `columnForTest` ...");
// the first alter is commited

Is there a way to achieve atomicity (all-or-nothing behavior) with alter?

Thanks in advance

+3
source share
1 answer

ALTER TABLE ( DDL) , . Spring JDBC . , .

, , , .

+4

Source: https://habr.com/ru/post/1754444/


All Articles