码迷,mamicode.com
首页 > 编程语言 > 详细

SpringDataJpa 实体类过滤伪删除

时间:2019-08-24 00:17:01      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:man   user   rate   private   map   click   data   getters   active   

当需要过滤实体类的数据时,根据伪删除字段进行过滤,需要使用Hibernate提供的@Where注解

使用方式:

技术图片
@Entity(name = "Account")
@Where( clause = "active = true" )
public static class Account {

    @Id
    private Long id;

    @ManyToOne
    private Client client;

    @Column(name = "account_type")
    @Enumerated(EnumType.STRING)
    private AccountType type;

    private Double amount;

    private Double rate;

    private boolean active;

    //Getters and setters omitted for brevity

}
View Code

 

官方文献:https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#pc-where

 

注意:@Where部分注解不支持超类(@MappedSuperClass),需要定义在需要使用的具体实体类上

 

SpringDataJpa 实体类过滤伪删除

标签:man   user   rate   private   map   click   data   getters   active   

原文地址:https://www.cnblogs.com/XingXiaoMeng/p/11403177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!