[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2799?page=c...
]
Henri Tremblay commented on HHH-2799:
-------------------------------------
I'm using Hibernate 3.2.4-sp1 with Hibernate annotations 3.3.0-ga. With Oracle. I
think have the same issue. Let's consider:
@Column(scale = 4) public BigDecimal getRate() { return rate; }
or
@Column public BigDecimal getRate() { return rate; }
Both will generate a DB field like this: RATE numer(19,2)
In my case the "2" wasn't expected at all since the default scale for
@Column is 0.
I did some debugging and the issue comes from
1- Ejb3Column.java
if ( precision > 0 ) { //revelent precision
this.mappingColumn.setPrecision( precision );
this.mappingColumn.setScale( scale );
}
-> This keeps the default scale for a column which is "2", not zero. A
workaround is then to specify @Column(precision=19, scale=127) but not really nice.
2- SchemaExport always set scale and precision to what's in Column
(TypeNames.replace).
-> So you get number(19,2)
At least for Oracle, I think we should have some "null" value to allow no
precision and no scale.
But right now, having a 2 appearing is quite puzzling.
Default Scale value doesn't right
---------------------------------
Key: HHH-2799
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2799
Project: Hibernate3
Issue Type: Bug
Components: metamodel
Affects Versions: 3.2.0.ga
Environment: Name and version of the database you are using:MySQL 5.0.37
Reporter: Bliznets Roman
Original Estimate: 2 hours
Remaining Estimate: 2 hours
In my Mapping documents:
...
<property name="goodsNumeric" lazy="false" insert="true"
update="true" not-null="false" unique="false"
type="java.math.BigInteger">
<column not-null="false" unique="false"
name="`goodsnumeric`" precision="5"/>
</property>
...
From MySQL documentation
In standard SQL, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0).
But In log and in database scale=2, it's have to be exactly 0.
Debug level Hibernate log excerpt:
12484 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create table
`goodsitembasetype` (e_id bigint not null auto_increment, e_version integer not null,
`goodsnumeric` numeric(5,2), `grossweightquantity` numeric(19,6), `netweightquantity`
numeric(19,6), `invoicedcost` numeric(16,2), `customscost` numeric(16,2),
`statisticalcost` numeric(16,2), primary key (e_id))
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira