Skip to content
This repository has been archived by the owner on Aug 15, 2020. It is now read-only.

JDBC can rollback , but Mybatis can't #207

Open
SmallBeautifulPig opened this issue Feb 24, 2020 · 0 comments
Open

JDBC can rollback , but Mybatis can't #207

SmallBeautifulPig opened this issue Feb 24, 2020 · 0 comments

Comments

@SmallBeautifulPig
Copy link

When I was testing the official sharding-seata demo ,the following problems are encountered.

private static Long insertOrder(final Connection connection, final Order order) { String sql = "INSERT INTO t_order (user_id, address_id, status) VALUES (?, ?, ?)"; try (PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { preparedStatement.setObject(1, order.getUserId()); preparedStatement.setObject(2, order.getAddressId()); preparedStatement.setObject(3, order.getStatus()); preparedStatement.executeUpdate(); try (ResultSet resultSet = preparedStatement.getGeneratedKeys()) { if (resultSet.next()) { order.setOrderId(resultSet.getLong(1)); } } } catch (final SQLException ignored) { } return order.getOrderId(); }

the original JDBC can rollback . but when replaced by mybatis , it can't be rollbacked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant