-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem mapping decimal field
PostPosted: Tue Mar 13, 2007 8:37 am 
Beginner
Beginner

Joined: Tue Mar 13, 2007 8:26 am
Posts: 25
Hello,

I have in my firebird database the following field: LARGURA DECIMAL(4,2)

And I mapped as follow:

Code:
private float largura;

// ...

    @Column(name = "LARGURA")
    public float getLargura() {
        return largura;
    }

    public void setLargura(float largura) {
        this.largura = largura;
    }



But I'm getting a erro message:

Quote:
Caused by: org.hibernate.HibernateException: Wrong column type: LARGURA, expected: float
at org.hibernate.mapping.Table.validateColumns(Table.java:261)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)


How do I map a decimal field using annotations?


Thanks,

_________________
---
Felipe Marin Cypriano


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 10:02 am 
Newbie

Joined: Wed Feb 01, 2006 10:45 am
Posts: 18
Location: Salzburg, Austria
have you tried using BigDecimal?

_________________
greetings,
kris


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 10:19 am 
Beginner
Beginner

Joined: Tue Mar 13, 2007 8:26 am
Posts: 25
Hi kristian,

Yes, take a look:

Code:
    @Column(name = "LARGURA", precision = 4, scale = 2)
    public BigDecimal getLargura() {
        return largura;
    }

    public void setLargura(BigDecimal largura) {
        this.largura = largura;
    }


Now the erro is:
Quote:
Caused by: org.hibernate.HibernateException: Wrong column type: LARGURA, expected: numeric(4,2)
at org.hibernate.mapping.Table.validateColumns(Table.java:261)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)



The field is decimal(4,2). Why this? DECIMAL and NUMBER are incopatibles?

In hibernate.cfg.xml:
Code:
...

<property name="hbm2ddl.auto">validate</property>
...

_________________
---
Felipe Marin Cypriano


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.