Pivotal Knowledge Base


Fail to get correct result with a Query on Enum object


Pivotal GemFire 8 and above


Queries on partitioned regions that involve an Enum object field may give incorrect results when the relevant domain class implements PdxSerializable.

For example:

gfsh>query --query="selelct testEnum from /exampleRegion where testEnum.code = 1 " 
Result : true
startCount : 0
endCount : 20
Rows : 0

public enum TestEnum {
	A(1, "AA"), B(2, "BB"), C(3, "CC"), D(4, "DD");

	private int code;
	private String desc;

	private TestEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;

	public int getCode() {
		return code;

	public void setCode(int code) {
		this.code = code;

	public String getDesc() {
		return desc;

	public void setDesc(String desc) {
		this.desc = desc;
public class TestStatus implements PdxSerializable {
	public TestStatus() {


	public TestStatus(TestEnum testEnum) {
		this.testEnum = testEnum;


Queries like the above are invalid because the call to testEnum.code involves a static class and method invocation, since Java enum types are implicitly static, which is not supported.


To write a query using the value of an Enum object field on a partitioned region, you must use the toString method of the enum object or use a query bind parameter.

For example:

gfsh>query --query="selelct testEnum from /exampleRegion where testEnum.code.toString() = 1"

Additional Information

For additional information on troubleshooting queries on Enum Objects, see the relevant section in the User's Guide.


Powered by Zendesk