This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HibernateException - Wrong column type

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting the following error when deploying my code. I think it is a problem with the mapping, but I don't know what's wrong with it. I've included my mapping file, database create so you know how the table was created, a domain object snipet, and the Hibernate properties I have set. I'm using xdoclet2 to create the mapping file. I'm running this on Weblogic 8.1.6, Windows XP (development environment) and DB2 8.x. I've tried this while using double and Double as the types in the domain object, and I get the same error, except "numeric(15,2)" was replaced with "double". Any ideas what I've done wrong?


error
org.hibernate.HibernateException: Wrong column type: RATE, expected: numeric(15,2)
at org.hibernate.mapping.Table.validateColumns(Table.java:251)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1007)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)


mapping
<hibernate-mapping>
<class table="PROJECT_FINANCE_RATE_EMPLOYEE" name="com...FinanceRateEmployee">
<composite-id unsaved-value="none" name="financeRateEmployeeID" class="com...FinanceRateEmployeeID">
<key-property name="costCenter" column="COST_CENTER"/>
<key-property name="effectiveDate" column="EFFECTIVE_DATE" type="date"/>
<key-property name="eptRole" column="EPT_ROLE_ID" type="integer"/>
<key-property name="orgId" column="ORG_ID"/>
</composite-id>
<property name="createdAt" column="CREATED_AT" type="timestamp"/>
<property name="createdBy" column="CREATED_BY"/>
<property name="lastChangedAt" column="LAST_CHANGED_AT" type="timestamp"/>
<property name="lastChangedBy" column="LAST_CHANGED_BY"/>
<property name="rate" scale="2" column="RATE" precision="15" type="big_decimal"/>
</class>
</hibernate-mapping>


database create statement for the table
CREATE TABLE "EPTOWNER"."PROJECT_FINANCE_RATE_EMPLOYEE"
("ORG_ID" VARCHAR(10) NOT NULL,
"COST_CENTER" VARCHAR(10) NOT NULL,
"EPT_ROLE_ID" INTEGER NOT NULL,
"EFFECTIVE_DATE" DATE NOT NULL,
"RATE" DECIMAL(15, 2) NOT NULL,
"CREATED_BY" VARCHAR(8) NOT NULL,
"CREATED_AT" TIMESTAMP NOT NULL DEFAULT CURRENT TIMESTAMP,
"LAST_CHANGED_BY" VARCHAR(8) NOT NULL,
"LAST_CHANGED_AT" TIMESTAMP NOT NULL DEFAULT CURRENT TIMESTAMP
)


domain object snipet
private BigDecimal rate;
/**
* @hibernate.property column="RATE"
* type="big_decimal"
* precision="15"
* scale="2"
* @return rate
*/
public BigDecimal getRate() {
return rate;
}
public void setRate(BigDecimal rate) {
this.rate = rate;
}


hibernate Properties I have set
<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.show_sql">true</prop>
 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using
"RATE" NUMERIC(15, 2) NOT NULL,
instead of
"RATE" DECIMAL(15, 2) NOT NULL,
in table definition

or in the hibernate mapping file and data object use

type="double"

instead of

type="big_decimal"

Because according to Java Persistence with Hibernate book
big_decimal is compatible with NUMERIC type in SQL

Rgds,
Paras
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had our DBA change the data type to NUMERIC, however, with DB2, there is no difference between NUMERIC and DECIMAL. When the table gets created it is still created as DECIMAL. I also had the DBA change the precision to 6 with a scale of 2. So, in the database, the column in question shows as DECIMAL(6,2) currently. I have no changes in functionality after these changes. Also, I tried to set the type as double and Double, before my original post, and I then received the same error, except that instead of "numeric(15,2)" is read as "double". Do you have any other suggestions?
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic