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)