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.