找准目标,不断前行

select和insert同一事务 导致死锁的一种情况

@Transactional(rollbackFor = Exception.class, transactionManager = "aTransactionManager", isolation = Isolation.READ_COMMITTED)
public R testDeadlock(@RequestBody Map<String, Object> paraMaps){
    	
	//删除待测试是否锁表的测试表TEST_INSERT
	aDao.deleteTest();
	
	List<Map<String,Object>> listAll = aDao.selectTest();
	
	for (int i = 0; i < listAll.size(); i++) {
		
		System.err.println(listAll.get(i).get("a"));
		//循环写入 TEST_INSERT.. 此时访问 TEST_INSERT
		aDao.insertTest(listAll.get(i));
		
	}
	
	return R.ok();
}


<select id="selectTest" parameterType="map" resultType="map">
    SELECT
      a,b,c,d,e
    FROM
    TEST_SELECT
</select>

<insert id="insertTest"  parameterType="map" >
	insert into 
	  TEST_INSERT(a,b,c,d,e)
	values
	(#{a},#{b},#{c},#{d},#{e})
</insert>

<insert id="deleteTest"  parameterType="list" >
	delete from TEST_INSERT
</insert>
 

  

posted @ 2023-10-18 09:18  kevinZhuZhu  阅读(55)  评论(0编辑  收藏  举报