![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
springdatajpa
harry5508
寒叶知秋,进阶中...
展开
-
关于SpringDataJPA批量保存数据时报错的解决
话不言多,言简意赅就好。 用Springboot+Swagger+SpringDSataJPA框架在写网页投票接口的时候,多选批量保存数据入库(在此用的数据库为MySQL),报错:a different object with the same identifier value was already associated with the session 。 意思是:在一个session中不...原创 2018-06-29 13:43:13 · 2128 阅读 · 0 评论 -
SpringDataJPA的JPQL语句
今天发现JPQL语句居然条件可以是 “!=null“,解决一个苦恼的问题,哈哈,后知后觉吧~大家可以试试。原创 2018-07-02 09:28:24 · 641 阅读 · 0 评论 -
【转】Spring-data-JPA生成JPQL语句方法名称中支持的关键字
方法名称中支持的关键字关键字示例JPQL 片段AndfindByLastnameAndFirstname… where x.lastname = ?1 and x.firstname = ?2OrfindByLastnameOrFirstname… where x.lastname = ?1 or x.firstname = ?2Is,EqualsfindByFirstname,findByFir...转载 2018-07-02 09:31:05 · 154 阅读 · 0 评论 -
【MySQL用JPA批量删除】check the manual that corresponds to your MySQL server version for the right syntax错误
错误的语句: @Query(value = "delete from Topic t where t.topicIndustry.id=?", nativeQuery = true) void deleteByTopicIndustry(@param("id")int id); 修改后的语句: @Query( "delete from Topic t where t.topicInd...原创 2018-07-10 15:04:11 · 1270 阅读 · 0 评论 -
关于SpringDataJPA批量保存数据时报错的解决
话不言多,言简意赅就好。用Springboot+Swagger+SpringDSataJP框架在写网页投票接口的时候,多选批量保存数据入库(在此用的数据库为MySQL),报错:a different object with the same identifier value was already associated with the session 。意思是:在一个session中不能进行多个...原创 2018-07-10 15:10:16 · 2819 阅读 · 1 评论 -
使用JPA中@Query 注解实现update 操作
使用JPA中@Query 注解实现update 操作,代码如下: @Transactional @Modifying(clearAutomatically = true) @Query(value = "update info p set p.status =?1 where p.id = ?2",nativeQuery = true) int updateStatusById( Strin...原创 2018-07-13 17:15:33 · 3025 阅读 · 0 评论 -
Spring JPA查询,JPA 根据方法名字查询
最近新项目又使用了jpa。 对JPA简直又爱又恨。。。基本能满足了所有的基本查询,还基本不用写sql语句,但是。。。。弊端就不说了吧。 下面来详细看下支持的查询方式。 根据方法名字生成SQL语句(根据方法名查询) public interface UserRepository extends Repository<User, Long> { List<User&g...原创 2019-04-28 14:34:11 · 1152 阅读 · 0 评论