-->
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.  [ 2 posts ] 
Author Message
 Post subject: Informix big_decimal and scale
PostPosted: Fri Jul 15, 2005 5:13 pm 
Newbie

Joined: Fri Jul 15, 2005 3:34 pm
Posts: 2
Location: Portland, OR
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0.5

Name and version of the database you are using:Informix 9.4, JDBC Driver 2.21 JC6

I am trying to map a column in a table in Informix that is defined as decimal(11,8) in the database to a BigDecimal. The problem I am getting is that the scale of the BigDecimal that I get when I use the Hibernate mapping is always 6, regardless of what I set the "scale" property to in the Hibernate mapping file.

Here is a sample schema:

Code:
create table station
  (
    station_key serial ,
    station_name varchar(40,14) not null ,
    latitude decimal(11,8),
    longitude decimal(11,8),
    primary key (station_key) constraint pk_station
);

Here is a sample mapping file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="wcc.database.awdb" default-lazy="false" >
  <class name="Station" table="station" mutable="false" >
    <!-- Declare the primary key. --> 
    <id name="key" type="integer" unsaved-value="0">
      <column name="station_key" not-null="true" />
      <generator class="identity"/>
    </id>

    <property name="name" column="station_name" not-null="true"/>
    <property name="latitude" column="latitude" scale="8" type="big_decimal"/>
    <property name="longitude" column="longitude" scale="8" type="big_decimal" />
  </class>
</hibernate-mapping>



What ends up happening is that the longitude and latitude fields of my class always have a scale of 6, regardless of whether or not I set the scale attribute in the mapping file, and regardless of the value of the scale attribute. If I use JDBC to query the table directly, I get the correct scale on the BigDecimal. Am I missing anything or doing something wrong? Any help would be greatly appreciated. Thanks.

>Dipesh.


Top
 Profile  
 
 Post subject: Disregard previous post - it was an error in my code
PostPosted: Thu Jul 21, 2005 10:59 am 
Newbie

Joined: Fri Jul 15, 2005 3:34 pm
Posts: 2
Location: Portland, OR
Please disregard my post. I found an error somewhere else in my code that was unrelated to Hibernate that was causing the scale to be set to 6. Hibernate is working correctly.


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

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.