Hello,
I'm rather new to Hibernate and I am having problems mapping BigDecimals to a PostgreSQL database. While Hibernate maps them correctly to numerics, it seems to ignore my precision/scale specification completely. I also tried to used the length parameter instead of precision, but the outcome is the same. I searched the web and this forum but no one seems to be having the same problem, so it has to be something I am doing wrong and I fail to realize what it is.
Any help would be really appreciated.
Regards,
Diego
-----
Hibernate version:
3.0.5
Mapping documents:
This is the xml file for the mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.anankesoftware.test.TestClass" table="testclass">
<id name="id" column="id" access="field">
<generator class="sequence"/>
</id>
<property name="aBigDecimal" type="big_decimal" column="a_big_decimal" precision="10" scale="2"/>
</class>
</hibernate-mapping>
This is the class I am trying to map:
Code:
public class TestClass {
private long id;
private BigDecimal aBigDecimal;
public BigDecimal getaBigDecimal() {
return aBigDecimal;
}
public void setaBigDecimal(BigDecimal aBigDecimal) {
this.aBigDecimal = aBigDecimal;
}
public TestClass() {
}
}
This is the table it generates:
Code:
CREATE TABLE testclass
(
id int8 NOT NULL,
a_big_decimal numeric,
CONSTRAINT testclass_pkey PRIMARY KEY (id)
)
Name and version of the database you are using:
PostgreSQL 8.0.2