org.springframework.orm.hibernate3.HibernateSystemException: More than one row with the given identifier was found: 96739392, for class

问题:根据id查询订单报错,查出来多个。order = orderService.findById(n.getOrderId());

原因:hibernate映射关系一对多,回根据id查出来多条记录,然后抛出异常。

解决方案:

使用原生sql查询。select * from order where id = '111';

然后在外部捕获异常,一条数据出问题,不影响其他数据查询。保证定时任务执行完。

 

posted @ 2024-07-17 18:54  黎明的太阳  Views(6)  Comments(0Edit  收藏  举报