Search code examples
javajpaannotations

Setting default values for columns in JPA


Is it possible to set a default value for columns in JPA, and if, how is it done using annotations?


Solution

  • Actually it is possible in JPA, although a little bit of a hack using the columnDefinition property of the @Column annotation, for example:

    @Column(name="Price", columnDefinition="Decimal(10,2) default '100.00'")