-->
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.  [ 1 post ] 
Author Message
 Post subject: Derby dialect maps float wrong
PostPosted: Wed Nov 26, 2008 4:43 pm 
Newbie

Joined: Wed Nov 26, 2008 4:13 pm
Posts: 1
Hibernate version:
Hibernate Core 3.3.1.GA

Name and version of the database you are using:
Apache Derby 10.4.2.0

Hello,

I'm using Hibernate to create a table from the hbm.xml mapping.

The hibernate mapping is as follows:

Code:
<hibernate-mapping package="com.examples">
   
   <class name="MyClass" table="MY_TABLE">
      
      <id name="id" column="MY_ID" type="long">
         <generator class="increment"/>
      </id>
      
      <property name="offset" column="OFFSET" type="float"/>
   </class>

</hibernate-mapping>



When Hibernate create the table, the DDL says:

Code:
create table MY_TABLE (MY_ID bigint not null, OFFSET float, primary key (MY_ID))


But at the end, the offset column is type DOUBLE.

The Derby documentation (http://db.apache.org/derby/docs/10.1/re ... 27281.html) explains this:

If you use float, the default precision is 53 so you will end with double (double precision).

To get a single precision float you must specify a precision of 23 or less.


The Derby dialect maps the "float" java type to the "float" derby type. That's wrong because the implicit precision is 53 and that will produce a double.


The Derby dialect should map the "float" java type to the "float(23)" derby type.


I have also used the "precision" attribute in the column mapping, like this:

Code:
<property name="offset" column="OFFSET" type="float" precision="23"/>


But that has no effect.

What do you think?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.