springData jpa update delete

使用@Modifying + @Query 实现springData 对数据的 update delete


public interface ICustomer extends JpaRepository<Customer, Long>
{
    @Modifying
    @Query("delete Customer where isLogicDel = 0 and dispatchDate  = ?1 ")
    public int deleteCustomer(Date dispatchDate);
    
    
    @Modifying
    @Query("update Customer d set d.isLogicDel = 1  where d.member.id = ?1 and d.dispatchDate  = ?2 ")
    public int updateCustomer(Long memberId, Date dispatchDate);

    @Modifying
    @Query("update ComAbsUserExEntity u set u.totalWorkDays = :twd, u.nowCompanyId = :ncid, u.nowTeamId = :ntid, u.nowPlanId = :npid, u.nowCodeId = :ncdid  where d.id = :uid")
    public int updateUserEx(@Param("uid") long userId, @Param("twd") double totalWorkDays,
            @Param("ncid") long nowCompanyId, @Param("ntid") long nowTeamId, @Param("npid") long nowPlanId,
            @Param("ncdid") long nowCodeId);  
              
}


你可能感兴趣的:(jpa,update,springdata)