spring boot实体类注解浅析

@Getter  =>get方法

@Setter  =>set方法

@Entity  =>指定这是一个实体Bean

@SequenceGenerator(name = "default",sequenceName = "SEQ_CONTRACT",allocationSize = 1)  =>定义一个生成主键的序列(名称/自增长)

@Where(clause = "IS_DELETED = 0")  =>hibernate中有@SQLDelete和@Where这两个注解,实现逻辑删除

@SQLDelete(sql = "UPDATE CONTRACT SET IS_DELETED=1 WHERE id=? AND VERSION=?")
@Table(name="CONTRACT ")  =>指定表名

@EntityListeners(AuditingEntityListener.class)  =>实体类监听器

public class Contract extends BaseEntity {

@Id

@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "default")

protected Long id;

 

@Version   =>用于在实体Bean中添加乐观锁支持。

@Column(nullable = false,columnDefinition = "NUMBER(10,0) DEFAULT 0")  =>声明该属性与数据库字段的映射关系。

protected Integer version;

 

 @OneToMany(mappedBy=” person”,cascade=CascadeType.ALL,fetch=FetchType.LAZY)  =>一对多声明

 

 @ManyToOne(fetch = FetchType.LAZY)
 @JoinColumn(        ==>不生成外键
            foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))     =>一对多声明 

 

 @OneToOne(fetch = FetchType.LAZY) 
 @JoinColumn(
            foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))       =>一对一声明

@ManyToMany(fetch = FetchType.LAZY,mappedBy = "storageGrounds")
@org.hibernate.annotations.ForeignKey(name = "none")      =>多对多声明


}

 

你可能感兴趣的:(spring boot实体类注解浅析)