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.
Example:
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>
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.
Example: SELECT * FROM /ID_Region t WHERE t.SampleID=9111221001L
Solution 2
Use method in domain class to convert the number into String. Example:
SELECT * FROM /ID_Regionn t WHERE t.SampleID. toString()='9111221001'
Solution 3
Add suffix "." or ".0" to convert the number into double type. Example:
SELECT * FROM /ID_Region t WHERE t.SampleID=9111221001. SELECT * FROM /ID_Region t WHERE t.SampleID=9111221001.0