How to specify Double's precision on hibernate?

后端 未结 4 702
温柔的废话
温柔的废话 2020-12-08 03:01

I try to create a table from hibernate annotations. I need to have a column of Double type, with the length specified like : (10,2). So SQL syntax show like:



        
4条回答
  •  庸人自扰
    2020-12-08 03:27

    Use @Type (only in Hibernate):

    @Column(precision = 5, scale = 4)
    @Type(type = "big_decimal")
    private double similarity;
    

    Will result in definition (PostgreSQL, Oracle):

    similarity numeric(5, 4),
    similarity number(5, 4)
    

提交回复
热议问题