类 UpdatePoUtil


  • public class UpdatePoUtil
    extends Object
    处理JPA中的PO持久化,会用null值更新已有的属性值 支持要复制又不全部复制的做法
    作者:
    youta
    • 构造器详细资料

      • UpdatePoUtil

        public UpdatePoUtil()
    • 方法详细资料

      • copyNullProperties

        public static void copyNullProperties​(Object source,
                                              Object target,
                                              String... ignoreProperties)
        将目标源中不为空的字段过滤,将数据库中查出的数据源复制到提交的目标源中
        参数:
        source - 用id从数据库中查出来的数据源
        target - 提交的实体,目标源
        ignoreProperties - 忽略的属性,比如有些属性更新时间需要每次都变,可以不复制
      • getNoNullProperties

        private static String[] getNoNullProperties​(Object target,
                                                    String... ignoreProperties)
        参数:
        target - 目标源数据
        返回:
        将目标源中不为空的字段取出, 并将传进来的不需要复制的字段合并