-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: PostgreSQL numeric type without precision/scale
PostPosted: Mon Oct 19, 2015 2:53 pm 
Newbie

Joined: Mon Oct 19, 2015 2:38 pm
Posts: 4
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.