Pivotal Knowledge Base


GemFire Error "unable to parse integer" Running Query on BigDecimal Field


 Pivotal GemFire versions from 7.x to 8.x
All Supported Operating Systems


When attempting to run a query with a "Where" clause on a BigDecimal field, it throws the below exception and fails to return a result.


The Domain class has a BigDecimal field like the one below:

private BigDecimal SampleID;
	public BigDecimal getSampleID()
		return SampleID;
	public void setSampleID( BigDecimal SampleID )
		SampleID = SampleID;
	public String toString() {
		return "Id [SampleID=" + SampleID + "]";

gfsh>query --query='SELECT * FROM /ID_Region t WHERE t.SampleID=9111221001';

Result     : false
startCount : 0
endCount   : 20
Message    : Query is invalid due for error :<Syntax error in query:  unable to parse integer:  9111221001> 


When the OQL parser gets a value of 9111221001 from a WHERE clause, it decides that the number is an integer by default like Java does. Since this value of 9111221001 is over the integer's maximum value of 2147483647, the OQL parser returns this error. 


To work around this error, there are several solutions.

Solution 1

Add suffix "L" like Java to the number to convert the number to Long type.
For example:
SELECT * FROM /ID_Region t WHERE t.SampleID=9111221001L

Solution 2

Use method in domain class to convert the number into String.
For example:
SELECT * FROM /ID_Regionn t WHERE t.SampleID. toString()='9111221001'

Solution 3

Add suffix "." or ".0" to convert the number into double type.
For example:
SELECT * FROM /ID_Region t WHERE t.SampleID=9111221001.
SELECT * FROM /ID_Region t WHERE t.SampleID=9111221001.0



Powered by Zendesk