-->
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.  [ 10 posts ] 
Author Message
 Post subject: Problem with float
PostPosted: Mon Nov 27, 2006 12:38 pm 
Newbie

Joined: Mon Nov 27, 2006 12:28 pm
Posts: 5
Hello,

I have a problem with a property in a mapping file:

<property name="longitude" type="float">
<column name="LONGITUDE" precision="22" scale="5" />
</property>

Initial SessionFactory creation failed.org.hibernate.HibernateException: Wrong column type: LATITUDE, expected: float
java.lang.ExceptionInInitializerError
at com.tz.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:33)
at com.tz.testHibernate(TelegramTester.java:34)
at com.tz.main(TelegramTester.java:137)
Caused by: org.hibernate.HibernateException: Wrong column type: LATITUDE, expected: float
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)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at com.astron.tims.util.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:28)
... 2 more
Exception in thread "main"
Java Result: 1


I use Oracle RDBMS.

Could you help me?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 12:43 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Could you paste your POJOs definitions?

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 12:52 pm 
Newbie

Joined: Mon Jan 05, 2004 11:04 am
Posts: 16
Hi,

in your mapping file you have LONGITUDE and
in the exception there is LATITUDE.

I hope it's an copy&paste error.

If not please post the part of the mapping file with the
LATITUDE attribute.

_________________
_________________
Siegbert

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 3:18 am 
Newbie

Joined: Mon Nov 27, 2006 12:28 pm
Posts: 5
Sorry for the error.
The mapping of the latitude is the same:

<property name="latitude" type="float">
<column name="LATITUDE" precision="22" scale="5" />
</property>

And the appropriate part of the POJOs definition is

private float latitude;

public float getLatitude() {
return latitude;
}

public void setLatitude(float latitude) {
this.latitude = latitude;
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 5:28 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
OK.

Now post the table definition in oracle...

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 8:06 am 
Newbie

Joined: Mon Nov 27, 2006 12:28 pm
Posts: 5
CREATE TABLE IMP_TEL_GPS
(
TEL_ID NUMBER NOT NULL,
GPS_MOBILE_ID VARCHAR2(64) NOT NULL,
CUR_SPEED NUMBER(3) NOT NULL,
CUR_DIR VARCHAR2(1) NOT NULL,
SAT_COUNT NUMBER(5) NOT NULL,
LATITUDE NUMBER(22,5) NOT NULL,
LONGITUDE NUMBER NOT NULL
);

ALTER TABLE DWHOWNER.IMP_TEL_GPS ADD
CONSTRAINT PK_IMP_TEL_GPS
PRIMARY KEY (TEL_ID)
USING INDEX
ENABLE
VALIDATE;


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 8:16 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
I think you must use

java.math.BigDecimal instead of float in your mappin and POJO

for a NUMBER column of Oracle.

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 8:34 am 
Newbie

Joined: Mon Nov 27, 2006 12:28 pm
Posts: 5
Thank you, it helps.
What is the correct column type in the Oracle DB if I would like to use float member in my POJO object?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 8:48 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
I think you must use BigDecimal and not float...

This link may help you

http://www.java2s.com/Code/Java/Hiberna ... teType.htm

Please, if my answers did help you, rate them :)

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 9:30 am 
Newbie

Joined: Mon Nov 27, 2006 12:28 pm
Posts: 5
Thanks, it helps me.

There are FLOAT type in Oracle, but I didn't know it. If I use it, the mapping works with float member.


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