Julia19
Julia19

Reputation: 15

How to generate Decimal (9,2 ) from Hibernate

Is there any way to generate a Decimal(9,2) from Hibernate ? Right now I do it manually in the MySql database myself. IN the hibernate class I just use double.

Upvotes: 0

Views: 1121

Answers (1)

Microtribute
Microtribute

Reputation: 1062

You can use the @Column annotation like this:

class Product {
    ...

    @Column(name="cost", precision=9, scale=2)
    private BigDecimal cost;

    ...
}

Check out https://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/Column.html for more information.

Upvotes: 1

Related Questions