We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请先看《提问的智慧》,并尝试到 issue 列表 搜寻是否已经有人遇到过同样的问题。
BaseDao.getField()方法未正确过滤主键
public static void main(String[] args) { BaseDao<User, Long> userDao = new UserDao(null); List<Field> field = userDao.getField(new User(), false); System.out.println(field); }
返回结果中包含了被注解@pk标为主键的id。原因如下:
private List<Field> getField(T t, Boolean ignoreNull) { // 获取所有字段,包含父类中的字段 Field[] fields = ReflectUtil.getFields(t.getClass()); // 过滤数据库中不存在的字段,以及自增列 List<Field> filterField; Stream<Field> fieldStream = CollUtil.toList(fields).stream().filter(field -> ObjectUtil.isNull(field.getAnnotation(Ignore.class)) || ObjectUtil.isNull(field.getAnnotation(Pk.class))); // 是否过滤字段值为null的字段 if (ignoreNull) { filterField = fieldStream.filter(field -> ObjectUtil.isNotNull(ReflectUtil.getFieldValue(t, field))).collect(Collectors.toList()); } else { filterField = fieldStream.collect(Collectors.toList()); } return filterField; }
此函数过滤fieldStream时,filter中的两个过滤条件应当是与关系,并非或关系
BaseDao.getField()方法正确过滤掉被@pk注解标为主键的Field
使用||: 使用&&:
请提供其他附加信息帮助我们诊断问题。
The text was updated successfully, but these errors were encountered:
fix(demo-orm-jdbctemplate/BaseDao): 修复getField方法未正确过滤被注解@pk标注为主键的Field
c1d624f
Closes xkcoding#239
xkcoding
No branches or pull requests
请先看《提问的智慧》,并尝试到 issue 列表 搜寻是否已经有人遇到过同样的问题。
描述问题
BaseDao.getField()方法未正确过滤主键
返回结果中包含了被注解@pk标为主键的id。原因如下:
此函数过滤fieldStream时,filter中的两个过滤条件应当是与关系,并非或关系
期待的结果
BaseDao.getField()方法正确过滤掉被@pk注解标为主键的Field
截屏或录像
使用||:
使用&&:
其他信息
请提供其他附加信息帮助我们诊断问题。
The text was updated successfully, but these errors were encountered: