Spring Data JPA:如何创建“通过多个属性删除";方法? [英] Spring Data JPA: How to create "delete by multiple properties" method?
本文介绍了Spring Data JPA:如何创建“通过多个属性删除";方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过多个实体属性删除一个实体?
I want to delete an entity(ies) by multiple entity properties?
我知道如何使用 JPA 查询
(@Query
注释).
I know how to do it using JPA query
(@Query
annotation).
是否可以使用 派生查询
来做到这一点?如何在 JpaRepository
中命名这样的方法?
Is It possible to do it using derived query
? How to name such method in JpaRepository
?
推荐答案
直接命名为select方法:
It is straight forward as naming select method:
两个属性:
long deleteByIdAndUser(
@Param("id") Long id,
@Param("user") User user);
三个属性:
long deleteByIdAndUserAndStatus(
@Param("id") Long id,
@Param("user") User user,
@Param("status") String status);
等等
这篇关于Spring Data JPA:如何创建“通过多个属性删除";方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文