Day01:

2017-07-12  本文已影响0人  宇宙超人喵学长

1、如果想要强制性的决定entity中字段的数据类型
@org.hibernate.annotations.Type( type = "nstring" )
2、关于时间的注解
@Temporal(TemporalType.DATE)
适用于java.util.Date or java.util.Calendar 类型的字段
3、@Generated
never、insert、always
4、行的转换

@NaturalId
private String username;

@Column(name = "pswd")
@ColumnTransformer(
    read = "decrypt( 'AES', '00', pswd  )",
    write = "encrypt('AES', '00', ?)"
)
private String password;

private int accessLevel;

@ManyToOne(fetch = FetchType.LAZY)
private Department department;

@ManyToMany(mappedBy = "employees")
private List<Project> projects = new ArrayList<>();

@Type(type = "org.hibernate.userguide.mapping.basic.MonetaryAmountUserType")
@Columns(columns = {
    @Column(name = "money"),
    @Column(name = "currency")
})
@ColumnTransformer(
    forColumn = "money",
    read = "money / 100",
    write = "? * 100"
)
private MonetaryAmount wallet;

5、@Formula 某些借用数据库计算的问题
@Formula(value = "credit * rate")
private Double interest;
6、@Where筛选数据
@Entity(name = "Account")
@Where( clause = "active = true" )

上一篇 下一篇

猜你喜欢

热点阅读