Day01:

作者: 宇宙超人喵学长 | 来源:发表于2017-07-12 17:43 被阅读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" )

    相关文章

      网友评论

          本文标题:Day01:

          本文链接:https://www.haomeiwen.com/subject/mqubhxtx.html