Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3
The error may exist in co/yiiu/pybbs/mapper/PermissionMapper.java (best guess)
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: SELECT id,name,value,pid FROM permission WHERE id IN ()
Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3
解决方案1 co.yiiu.pybbs.service.PermissionService的selectByRoleId(Integer roleId)方法中修改如下
// 根据角色id查询所有的权限
public List selectByRoleId(Integer roleId) {
List rolePermissions = rolePermissionService.selectByRoleId(roleId);
List permissionIds = rolePermissions
.stream()
.map(RolePermission::getPermissionId)
.collect(Collectors.toList());
QueryWrapper wrapper = new QueryWrapper<>();
if (permissionIds.size() > 0) {
wrapper.lambda().in(Permission::getId, permissionIds);
}
List permissionList = permissionMapper.selectList(wrapper);
return permissionList;
}
`
对permissionIds的长度进行判断后再加查询条件。
解决方案2
把添加角色的功能加上,通过添加角色进行相应数据的处理
先在数据库中添加一个角色, 然后再页面的角色列表中点击这个角色的编辑按钮,直接500,sql异常, ` org.springframework.jdbc.BadSqlGrammarException:
Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3
The error may exist in co/yiiu/pybbs/mapper/PermissionMapper.java (best guess)
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: SELECT id,name,value,pid FROM permission WHERE id IN ()
Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3
解决方案1 co.yiiu.pybbs.service.PermissionService的selectByRoleId(Integer roleId)方法中修改如下
// 根据角色id查询所有的权限 public List