-->
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.  [ 2 posts ] 
Author Message
 Post subject: hbm2ddl returns an error if big_decimal type is specified
PostPosted: Fri Feb 25, 2005 2:19 am 
Newbie

Joined: Wed Feb 09, 2005 1:17 am
Posts: 2
Hibernate version:2.1.7c

Name and version of the database you are using:Oracle10g

Mapping documents:
Code:
<?xml version="1.0" encoding="EUC-JP"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping default-cascade="all" package="jp.co.test">
  <class name="Test" table="test" dynamic-update="true"
    optimistic-lock="version">
    <cache usage="read-write"/>

    <id name="piid" type="long" column="piid">
      <generator class="native"/>
    </id>
    <version name="version" column="version"/>
    <property name="modificationDate" type="timestamp"
      column="modification_date"/>
    <property name="price" type="big_decimal" column="price"/>
  </class>
</hibernate-mapping>


following is hibernate.properties
Code:
hibernate.dialect net.sf.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username test
hibernate.connection.password test
hibernate.connection.url jdbc:oracle:thin:@azteca:1521:bildb


When a big_decimal type is specified in a mapping file and hbm2ddl command is executed, the error of ORA-01728 will occur.

The cause of an error is because big_decimal is changed into NUMBER(19,255).

following is DDL which created by hbm2ddl
Code:
drop table test cascade constraints
drop sequence hibernate_sequence
create table test (
   piid number(19,0) not null,
   version number(10,0) not null,
   modification_date date,
   price number(19, 255),
   primary key (piid)
)
create sequence hibernate_sequence


Is this a bug?

As management,At first I perform hbm2ddl with options(--text --format),
next,I am performing, after changing NUMBER (19,255) in created SQL into NUMBER.

Is it OK even if a big_decimal type is matched with a NUMBER type?

The following is the command executed when sql was created.
Code:
hbm2ddl --text --format test.hbm.xml > test.sql


Is this problem solved in the following version?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 7:59 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
Default mapping of big_decimal under Oracle Dialect seems to be number(19,255). The max precision for number in oracle is 38, max scale 127 (127,38). Current workaround is to set length="38" on the property (see property grossWeight in mapping file below).

Hibernate version: 3.0 rc1

Name and version of the database you are using: Oracle10g

Mapping Documents:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
    <class
        name="com.dcs.quotations.entities.GoodsItem"
        table="GOODS_ITEM"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
        optimistic-lock="version"
    >

        <id
            name="id"
            column="ID"
            type="java.lang.String"
            length="32"
        >
            <generator class="uuid.hex">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-GoodsItem.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="class"
        />

        <property
            name="cube"
            type="java.math.BigDecimal"
            update="true"
            insert="true"
            access="property"
            column="CUBE"
        />

        <property
            name="grossWeight"
            type="java.math.BigDecimal"
            update="true"
            insert="true"
            access="property"
            column="GROSS_WEIGHT"
            length="38"
        />

        <property
            name="pieces"
            type="java.lang.Integer"
            update="true"
            insert="true"
            access="property"
            column="PIECES"
        />

        <set
            name="descriptionOfGoodsses"
            lazy="true"
            inverse="false"
            cascade="all"
            sort="unsorted"
        >

              <key
                  column="GOODS_ITEM_FK"
              >
              </key>

              <one-to-many
                  class="com.dcs.quotations.entities.DescriptionOfGoods"
              />

        </set>

        <set
            name="marksses"
            lazy="true"
            inverse="false"
            cascade="all"
            sort="unsorted"
        >

              <key
                  column="GOODS_ITEM_FK"
              >
              </key>

              <one-to-many
                  class="com.dcs.quotations.entities.Marks"
              />

        </set>

        <many-to-one
            name="packageType"
            class="com.dcs.quotations.entities.PackageType"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="PACKAGE_TYPE_FK"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-GoodsItem.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Output ddl:

Code:
create table GOODS_ITEM (
   ID varchar2(32) not null,
   class varchar2(255) not null,
   CUBE number(19,255),
   GROSS_WEIGHT number(19,38),
   PIECES number(10,0),
   PACKAGE_TYPE_FK varchar2(32),
   CONSIGNMENT_FK varchar2(32),
   primary key (ID)
);


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