Hi,
I am in the process of migrating a web application from Oracle to PostgreSQL. I am running into an issue with the difference in the way Postgres treats the numeric type. Postgres adds trailing zeros to fill out the scale portion of the numeric and Oracle does not. We use numerics to hold composite ids and the trailing zeros added by postgres disrupt id queries.
I would like to write a custom Postgress dialect that treats all numerics, regardless of scale/precision, as the generic (dynamic) numeric type. I have tried a few modifications with no success. I tried overriding the getHibernateTypeName() method (org.hibernate.dialect) to ignore scale and precision, but it is not working.
@Override public String getHibernateTypeName(int code, int length, int precision, int scale) throws HibernateException { String result; if(code == Types.NUMERIC) { result = getHibernateTypeName(code); } else { result = super.getHibernateTypeName(code, length, precision, scale); }
return result; }
Can anyone think of an elegant solution for this problem? Thanks.
|