hibernate实体类验证及连表

1.  BigDecimal
        :public static final BigDecimal MONEY_YZSP = BigDecimal.valueOf(99999999);
        
2.  @NotNull 
    
    @NotBlank
    
    @Digits(integer=10, fraction=2, message = "金额格式错误(请保留2为小数)")
    @DecimalMin(value = "0.01",message = "金额不能小于0.01元")
    
    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CONTRACT_CLASSFIY_ID", insertable = false, updatable = false)
    
    @JsonIgnore
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
    @JoinColumn(name = "CONTRACT_ID",insertable = false, updatable = false)
    private List<ContractReview> reviews;
    
    @JsonIgnore
    @OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.DETACH)
    @JoinColumn(name = "CONTRACT_CLASSFIY_ID", insertable = false, updatable = false)
    private List<Contract> contractList;
    
    //搜索用开始时间
    @Transient
    private Date startTime;
    
    if(ObjectUtils.isEmpty(department)|| StringUtils.isEmpty(department.getDepName()))
    import org.springframework.util.ObjectUtils;
    import org.springframework.util.StringUtils;
    
3.    @Entity
    @Table(name = "t_user")
    @Comment(value="用户表")
    public class User implements Serializable{
    private static final long serialVersionUID = 1L;
    
    @Column(nullable = false, name = "USER_ID", length = 20, unique = true, columnDefinition = "varchar(20) COMMENT '列中文名:用户ID'")
    
    @Excel(name = "姓名")
    
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "t_user_role", joinColumns = {@JoinColumn(name = "USER_ID", columnDefinition = "int COMMENT '列中文名:用户Id,列注释:用户表主键'")}, inverseJoinColumns = {
            @JoinColumn(name = "ROLE_ID", columnDefinition = "int COMMENT '列中文名:角色Id,列注释:角色表主键'")})
    @Excel(name = "角色")
    private List<Role> roleList;// 一个用户具有多个角色

    @JsonBackReference
    @ManyToOne(targetEntity = Department.class,fetch = FetchType.LAZY)
    @JoinColumn(name = "depId", insertable = false, updatable = false)
    @NotFound(action=NotFoundAction.IGNORE)
    private Department dep;
    
    

相关推荐
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页