-->
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: Overriding precision on Oracle NUMBER for primitive types
PostPosted: Fri Nov 28, 2008 8:34 pm 
Newbie

Joined: Thu Nov 27, 2008 8:01 pm
Posts: 3
Hibernate version:
3.2.3.GA

Name and version of the database you are using:
Oracle

Mapping documents:

This question relates to how Hibernate maps to Oracle data types when generating SQL from JPA configuration files using the hbm2ddl ant task.

If you have a property on your bean of type Long it is always mapped to an Oracle column of type NUMBER(19,0). If you specify a precision (or length) it is ignored.

In most cases this shouldn't be an issue as NUMBER(19,0) covers all of the possible values of a Long and Oracle doesn't use any more space than is required for the actual value.

Now if you were say mapping a legacy application which had columns with NUMBER(15,0)and you wanted to have the mapping file show this. Then if you needed to regenerate the DDL from the mapping file you would not get the same result which could lead to issues with data in different environments.

So the question is what is the best way to handle this in Hibernate, in relation to the JPA spec? I know you can use the columnDefinition to specify the exact value but on the whole I prefer not resort to that.

The following are fragments from a JPA orm.xml file.

Code:
      <basic name="quantity" >
        <column name="QUANTITY" precision="30" />
      </basic>


Code:
  public class OrderItem {
    private Long quantity;
      :
    }


Code:
COUNT number(19,0)


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