我有这个Java方法
@Override
public void callDelete_old_orders
(int order_id) throws Exception {
SqlSession sqlSession = getSqlSession();
OrderMapper mapper = sqlSession.getMapper(OrderMapper.class);
mapper.callDelete_old_orders(order_id);
}
与MyBatis的删除注释接口
public interface OrderMapper {
@Delete ("{CALL delete_old_orders(#{ order_id, mode = IN, jdbcType = INTEGER})} ")
@Options(statementType = StatementType.CALLABLE)
public void callDelete_old_orders(int order_id);
}
和程序
CREATE DEFINER=`myself`@`localhost` PROCEDURE `pizza_bro`.`delete_old_orders`(
IN in_order_id INT)
begin
delete from pizza_order where order_id <= in_order_id;
end
什么可以阻止记录从MariaDB表中删除?
我应该把commit语句放在mapper方法调用之后,如下所示:
@Override
public void callDelete_old_orders(int order_id) throws Exception {
SqlSession sqlSession = getSqlSession();
OrderMapper mapper = sqlSession.getMapper(OrderMapper.class);
mapper.callDelete_old_orders(order_id);
***sqlSession.commit();***
}