The reason you get a numeric(19,2) is because these are the defaults implemented in org.hibernate.mapping.Column :-
Code:
public static final int DEFAULT_LENGTH = 255;
public static final int DEFAULT_PRECISION = 19;
public static final int DEFAULT_SCALE = 2;
I've gotten around this by extending org.hibernate.dialect.PostgreSQLDialect :-
Code:
public class ImprovedPostgreSQLDialect extends PostgreSQLDialect {
@Override
public String getTypeName(int code, int length, int precision, int scale) throws HibernateException {
if (Types.NUMERIC == code && precision == org.hibernate.mapping.Column.DEFAULT_PRECISION &&
scale == org.hibernate.mapping.Column.DEFAULT_SCALE ) {
return "numeric";
}
return super.getTypeName(code, length, precision, scale);
}
}
which will return the more general "numeric" definition for the column instead of "numeric(19,2)". Note that this is not a perfect solution as you lose the ability to specify the precision in your database and instead rely on the face that you BigDecimal objects are set at the correct precision instead.