/*
//删除用户角色关系表无效 数据(careful:just execute once)
List<User> tempUsers = this.userDao.getUsers();
List<UserRole> tempUserRoles = this.userRoleManager.getAll();
for (UserRole duserRole : tempUserRoles) {
if(duserRole!=null){
boolean existRelationship = false;//check Whether the user_role's userId exist in user table. if not,delete
for (User duser : tempUsers) {
if(duser!=null){
if(duserRole.getUser().getId() == duser.getId() ){
existRelationship = true;
break;
}
}
}
if(!existRelationship){//如果该用户ID不存在于用户表,表示无效关系,就删除.
this.userRoleManager.deleteUserRole(duserRole.getId());
}
}
}
*/
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)