You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/02/24 01:47:02 UTC
[GitHub] [incubator-shardingsphere-example] SmallBeautifulPig opened a new
issue #207: JDBC can rollback , but Mybatis can't
SmallBeautifulPig opened a new issue #207: JDBC can rollback , but Mybatis can't
URL: https://github.com/apache/incubator-shardingsphere-example/issues/207
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.**
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services