Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Enums in SQLQuery and ArrayIndexOutOfBoundsException

Hello

I would like to use enum in SQLQuery. Enums are not supported by SQLQuery so following workaround was used:

  1. In enum class I declare additional property:

public enum State { /* Active */ A, /* Dismissed */ D;

public String getValue() { return name(); }

}

  1. SQLQuey looks as follows:

SQLQuery<MyClass> query = new SQLQuery<MyClass> (MyClass.class , "state.value in ("+paramValues+")"); State stateArr = new State[]{State.A, State.B}; query.setParameters(stateArr); MyClass ret [] = gigapace.readMultiple(query, Integer.MAX_VALUE);

  1. Definition of MyClass looks as follows:

class MyClass {

private State state;

public void setState(State state) { this.state = state; }

@SpaceIndex(path="value") public void getState() { return this.state }

}

And everything works fine until I want to write MyClass into space. ArrayIndexOutOfBoundsExceptions is thrown. When I comment out @SpaceIndex(path="value") everything works fine during write but field is not indexed. Why exception ArrayIndexOutOfBoundsExceptions is throw ? How to solve this issue without lose of indexing ?

Edited by: Lukasz Macha on Nov 10, 2010 2:05 AM

Edited by: Lukasz Macha on Nov 10, 2010 2:06 AM

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3540]{quote}

asked 2010-11-10 02:03:36 -0600

lukmac gravatar image

updated 2013-08-08 09:52:00 -0600

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

XAP 8 do support enum. see: http://www.gigaspaces.com/wiki/displa... Shay

answered 2011-02-17 10:41:35 -0600

shay hassidim gravatar image
edit flag offensive delete link more
0

Enum data types are not supported when using SQL queries. See http://www.gigaspaces.com/wiki/displa... Shay

answered 2010-11-12 13:15:26 -0600

shay hassidim gravatar image
edit flag offensive delete link more

Comments

As a workaround what I do is adding a new method to the enumeration like this:

public enum Status { ACTIVE, INACTIVE;

public String getName() { return name(); } }

And then you can use nested properties in the query like this:

status.name = 'ACTIVE'

It seems to work for us.

dgaviola gravatar image dgaviola  ( 2011-02-17 08:45:24 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2010-11-10 02:03:36 -0600

Seen: 169 times

Last updated: Feb 17 '11