【发布时间】:2018-11-28 02:15:57
【问题描述】:
但更新适用于以下代码 sn-p
Department department= departmentRepository.findOne(300L);
department.setName("rajiv");
departmentRepository.saveAndFlush(department);
但是这种情况是单色调映射,它可能是我最终会遇到 3 个查询的情况,其中包括 2 个选择查询和一个更新查询。 为了优化我更新它的方式,我正在尝试使用这种没有得到更新的方法,认为 executeUpdate() 将受影响的行返回为 1 。
【问题讨论】:
-
并且在以下情况下它不起作用 /* @Modifying(clearAutomatically = true) @Query("update Department d set d.name =:name where d.id=:id") int update( @Param("name")String name,@Param("id")Long id);*/ /*departmentRepository.update("Jerry",300L);*/
标签: spring-data-jpa spring-data