You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Yaocl <ch...@gmail.com> on 2012/10/13 04:08:43 UTC
Why not OpenJPA map BigDecimal to NUMERIC(precision, scale) on
database support NUMERIC
Hi
I use postgres in production environment, when using MappingTool to
generate DDL, I found openjpa map BigDecimal to NUMERIC but ignored
precision and scale specified in @Column.
When use openjpa with mysql. It can generate NUMERIC(precision,
scale). Finally I found because DBDictionary added NUMERIC into
fixedSizeTypeNameSet. So postgres not generate (precision, scale).
MySQLDictionary and SybaseDictionary removed NUMERIC from
fixedSizeTypeNameSet and these two database support (precision,
scale).
I haven't view all Dictionary class. Is there any reason to ignore
(precision, scale) of numeric on postgres? I known the postgres
database support NUMERIC(precision, scale) data type.
When use openjpa with DB2 and Derby. It use DOUBLE for BigDecimal,
Because numericTypeName defined to DOUBLE in AbstractDB2Dictionary.
<https://issues.apache.org/jira/browse/OPENJPA-1224> tried to fix it,
but finally
backed out changes because a test regression. DOUBLE cannot represent
decimal fractions exactly. Maybe we should consider to change it to
NUMERIC.
Regards,
YaoCL
Re: Why not OpenJPA map BigDecimal to NUMERIC(precision, scale) on database support NUMERIC
Posted by YaoCL <ch...@gmail.com>.
> I looked back through my emails from when I backed this change out and
> can't figure out which test I regressed. The reason that I backed the
> change out rather than fix the problem is because we were in the middle of
> trying to cut a release. I'll open a new JIRA soon here and just recommit
> the change to trunk for Derby / DB2 and fix the bug(s) when it rolls in.
Derby used in my unit test, I will test the trunk when you commit in. Originally I use HSQLDB 2.2.8
for my test. But HSQLDB dictionary ignore (precision, scale), unit test failed because my data round up to integer.
Than I changed to use Derby, It generate DOUBLE for BigDecimal so I researched this problem.
This is the workaround I am using now.
// For hsqldb
public class TestHSQLDictionary extends HSQLDictionary {
public TestHSQLDictionary() {
fixedSizeTypeNameSet.remove("NUMERIC");
}
}
//For Derby
public class TestDerbyDictionary extends DerbyDictionary {
/**
*
*/
public TestDerbyDictionary() {
super();
numericTypeName = "NUMERIC";
fixedSizeTypeNameSet.remove("NUMERIC");
nextSequenceQuery="SELECT NEXT VALUE FOR {0} FROM SYSIBM.SYSDUMMY1";
}
}
>> Is there any reason to ignore (precision, scale) of numeric on postgres?
> If I made the change for postgres, is this something you would be able to
> test?
I use postgres 9.1 in my project. I can test it with postgres 9.1.
Re: Why not OpenJPA map BigDecimal to NUMERIC(precision, scale) on
database support NUMERIC
Posted by Rick Curtis <cu...@gmail.com>.
I looked back through my emails from when I backed this change out and
can't figure out which test I regressed. The reason that I backed the
change out rather than fix the problem is because we were in the middle of
trying to cut a release. I'll open a new JIRA soon here and just recommit
the change to trunk for Derby / DB2 and fix the bug(s) when it rolls in.
> Is there any reason to ignore (precision, scale) of numeric on postgres?
If I made the change for postgres, is this something you would be able to
test?
Thanks,
Rick
On Fri, Oct 12, 2012 at 9:08 PM, Yaocl <ch...@gmail.com> wrote:
> Hi
>
> I use postgres in production environment, when using MappingTool to
> generate DDL, I found openjpa map BigDecimal to NUMERIC but ignored
> precision and scale specified in @Column.
> When use openjpa with mysql. It can generate NUMERIC(precision,
> scale). Finally I found because DBDictionary added NUMERIC into
> fixedSizeTypeNameSet. So postgres not generate (precision, scale).
> MySQLDictionary and SybaseDictionary removed NUMERIC from
> fixedSizeTypeNameSet and these two database support (precision,
> scale).
>
> I haven't view all Dictionary class. Is there any reason to ignore
> (precision, scale) of numeric on postgres? I known the postgres
> database support NUMERIC(precision, scale) data type.
>
> When use openjpa with DB2 and Derby. It use DOUBLE for BigDecimal,
> Because numericTypeName defined to DOUBLE in AbstractDB2Dictionary.
> <https://issues.apache.org/jira/browse/OPENJPA-1224> tried to fix it,
> but finally
> backed out changes because a test regression. DOUBLE cannot represent
> decimal fractions exactly. Maybe we should consider to change it to
> NUMERIC.
>
>
> Regards,
> YaoCL
>
--
*Rick Curtis*