Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » toNumber() expression with custom precision
toNumber() expression with custom precision [message #754369] Wed, 02 November 2011 11:06 Go to next message
dimo.velev is currently offline dimo.velevFriend
Messages: 13
Registered: August 2011
Junior Member

is there a way to specify the scale of the toNumber conversion in EclipseLink? My problem is that Microsoft SQL-Server uses default precision of 18.0 which causes values like 3.94 to be converted to 4.
As far as I can see in the source code it is not possible. Can anyone give me some pointers as to how to extend eclipselink with such functionality (basically add a new expression operator?

Thank you in advance,
Re: toNumber() expression with custom precision [message #754378 is a reply to message #754369] Wed, 02 November 2011 11:40 Go to previous message
dimo.velev is currently offline dimo.velevFriend
Messages: 13
Registered: August 2011
Junior Member
In case anyone else has similar problems. Currently I came up with the following workaround:
1. Create a custom platform DatabasePlatform extending from SQLServerPlatform:
public class CustomSQLServerPlatform extends SQLServerPlatform {
    private static final long serialVersionUID = 1L;
    protected void initializePlatformOperators() {

    protected void overwriteToNumberOperator() {
        final ExpressionOperator operator = new ExpressionOperator();
        final Vector v = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(2);

This way we can overwrite the toNumber() operator with one having a precision (in my case 10.Cool.
2. Instruct EclipseLink to use this platform manager by adding a property to the JPA persistence unit named "" with value the fully qualified class name of our customized database platform.

Previous Topic:Calling a stored procedure with BLOB input parameter
Next Topic:Custom sequence
Goto Forum:

Current Time: Wed Nov 25 12:42:04 GMT 2015

Powered by FUDForum. Page generated in 0.09491 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software