Integer.MIN_VALUE and Long.MIN_VALUE not properly handled as numeric literals in HQL parser

Description

In both cases this is due to the fact that the negation sign is handled seperately in the AST tree (as a UNARY_MINUS). This works out fine in the resulting SQL in the majority of cases.

However it breaks down specifically in the case of the MIN_VALUEs because of numeric overflow issues trying to parse the numbers. For both Integer and Long: ( MAX_VALUE == ( -MIN_VALUE ) - 1 ).

For example, for Integer: MIN_VALUE = -2e31 while MAX_VALUE = 2e31-1. Therefore the HQL:
("from Animal a where a.integer = " + Integer.MIN_VALUE) will fail because the negation sign is removed leaving 2e31 to be processed as the numeric literal value, which is bigger than Integer.MAX_VALUE.

I added a workaround while fixing such that a NumberFormatException on parsing an Integer will attempt to parse as a Long in anticipation that the format issue might be an overflow issue. Thus, really only Long.MIN_VALUE is currently a problem.

Activity

Show:

Steve Ebersole February 10, 2006 at 12:00 AM

In the grand scheme of things not a big deal. Plus I won't have time to get to this anytime soon

Won't Fix

Details

Assignee

Reporter

Components

Affects versions

Priority

Created January 23, 2006 at 4:10 PM
Updated February 10, 2006 at 12:01 AM
Resolved February 10, 2006 at 12:01 AM