相关疑难解决方法(0)

使用Spring JPA处理软删除

我有一个表Stuff定义为......

id, <fields>..., active
Run Code Online (Sandbox Code Playgroud)

Active是软删除标志,总是10.从长远来看,这可能会有利于历史表.

public interface StuffRepository extends JpaRepository<StuffEntity, Long> {} 
Run Code Online (Sandbox Code Playgroud)

在代码中,我们总是 使用活动记录.有没有办法让Spring始终active=1为为此存储库生成的查询附加条件?或者更理想的是允许我扩展用于生成查询的语法?

我知道我可以@queues在任何地方创建命名,但后来我失去了生成的查询的便利性.我还想避免使用"主动"方法污染接口.

我正在使用Hibernate 4.2作为我的JPA实现,如果这很重要的话.

java spring jpa spring-data spring-data-jpa

47
推荐指数
4
解决办法
3万
查看次数

标签 统计

java ×1

jpa ×1

spring ×1

spring-data ×1

spring-data-jpa ×1