JPA BigDecimal scale difference between Oracle and DB2 [message #708411] |
Tue, 02 August 2011 15:40  |
Eclipse User |
|
|
|
Hi forum,
An entity with field of type BigDecimal, scale 2, is handled (fetched) differently between Oracle and DB2.
(...)
@Entity
@Table(name = "ENTITYNUMBER")
public class EntityNumber implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private int id;
@Column(name="BIGDEC", nullable = false, unique = false, scale = 2, precision = 10)
private BigDecimal bigdec;
public EntityNumber() {
super();
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public BigDecimal getBigdec() {
return this.bigdec;
}
public void setBigdec(BigDecimal number) {
this.bigdec = number;
}
}
An entity (row) with column BIGDEC=12 is fetched as "12.00" from DB2 and "12" from Oracle, where
"12.00" means BigDecimal with scale=2
"12" means BigDecimal with scale=0.
In DB2 schema, the database column is defined as DECIMAL(10,2),
in oracle schema, the database column defined as NUMBER(10,2),
both generated by eclipselink DDL generation.
So the scale is ignored in oracle.
I cannot decide which behavior is expected, but it should be identical. Is this a bug, am I missing a configuration, or a restriction in portability?
I am using eclipselink 2.1.1.
Thanks
Rolf
[Updated on: Tue, 02 August 2011 15:44] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04706 seconds