The length
element of the Column annotation applies only if a string-valued column is used. In your case, you should use the precision
and the scale
elements.
@Column(precision=10, scale=2)
Here is what the specification writes about them:
int
- precision
- (Optional) The precision for a decimal (exact
numeric) column. (Applies only if a
decimal column is used.)
int
- scale
- (Optional) The scale for a decimal (exact numeric)
column. (Applies only if a decimal
column is used.)
References
- JPA 1.0 Specification
- Section 9.1.5 "Column Annotation"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…