这里写自定义目录标题
jpa+postgreSQL爬坑日记
为了简单使用,项目中引用jpa做持久层操作。
@query里的条件判断问题
起初使用别人介绍里的if 方法,启动时项目提示不存在这样的用法,后来又找一个新的写法,可用:
比如:(:#{#humanTempVo.code} = -1 or c_code = :{#humanTempVo.code})
** :#{#humanTempVo.code} 为引用传入对象的属性,直接传参的写法为:code
** 该code为Integer类型 ;
** =-1 表示当过滤条件code 为-1时 ,该where条件恒等,不再走code过滤,因此在传参时,若code未传值 则需将code设为-1 。
** 若code 为String 类型的 将 =-1 改为 =’’ (空字符串);
@query 出入时间参数的比较问题
@Query(nativeQuery = true, value = "select * from t_human_temp where d_happen_time>= date(:#{#humanTempVo.startDay}) ")
List<HumanTempDo> findHumanTempList(@Param("humanTempVo") HumanTempVo humanTempVo);
如上述代码,若HumanTempVo实体中 startDay为String类型,需在qu