JPA
胡萧徒
最怕一生碌碌无为,还安慰自己平凡可贵。
展开
-
JPA 多数据源 ,hikari 连接池 亲测可用
代码示例:https://gitee.com/Yohann_study/spring-boot-demo/tree/master/demo-multi-datasource-jpa原创 2022-03-02 15:35:00 · 543 阅读 · 0 评论 -
PostgreSQL 创建分区表,使用JPA插入报错
1.遇到的问题:org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 12.根本原因:JPA对 PostgreSQL 分区表进行数据插入的时候,因为数据实际插入的是分区表,主表没有数据,所以主表返回 "Affected rows: 0",但是hibernate源码中有一个方法: org.hiber原创 2022-02-18 18:29:43 · 1501 阅读 · 1 评论 -
JPA @Query 动态SQL
@Query("select * from user "+"WHERE case when (:userName is not null or :userName != '') then user_name like 'XXX%' else 1=1 end "+"OR case when (:userCode is not null or :userCode != '') then user_code = 'XXX' else 1 = 1 end "+)原创 2021-11-26 10:26:52 · 2788 阅读 · 0 评论