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

Ask Your Question
0

Nested Property Indexes

I have a nested property index defined as below:

@SpaceIndexes({@SpaceIndex(path = "firstName", type = SpaceIndexType.BASIC),
      @SpaceIndex(path = "lastName", type = SpaceIndexType.BASIC)

})

I am getting this exception which disappeared after I removed the index:

org.openspaces.core.UncategorizedSpaceException: Unknown property 'firstName' in 'class java.util.ArrayList'; nested exception is java.lang.IllegalArgumentException: Unknown property 'firstName' in 'class java.util.ArrayList'.

Why it is happening ?
Do I need to put the index as Extended for nested properties ?
Is the syntax correct ?
Do I have to implement equals or hashCode method for my class ? (How the Gigaspaces compares the nested property indexes for equality)

Thanks,

This thread was imported from the previous forum.
For your reference, the original is available here

asked 2010-06-10 13:04:04 -0500

omsoni gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

It seems you are trying to index nested properties in a property of type ArrayList, which is currently not supported.

Let's look at an example (similar to the example on www.gigaspaces.com/wiki/display/XAP71/Indexing#Indexing-Nestedpropertiesindexing):

public static class Person {
    private int id;
    private Info personalInfo;
    private String description;
    //getter and setter methods
...

// this defines a BASIC index on the personalInfo.socialSecurity property
    @SpaceIndex(path = "socialSecurity", type = SpaceIndexType.BASIC)
    public Info getPersonalInfo() {
         return personalInfo;
    }
}

public static class Info implements Serializable {
    private String name;
    private long socialSecurity;
    private int id;
    //getter and setter methods
}

The space index path is "socialSecurity", which means we're indexing personalInfo.socialSecurity (if the path is empty/not specified we're indexing personalInfo).
If the path was "socialSecurity1" we would get an exception saying: Unknown property 'socialSecurity1' in class 'Info'.

In your case, the exception is: Unknown property 'firstName' in 'class java.util.ArrayList', which suggests you are trying to index a nested property which doesn't exist in class ArrayList.

If that doesn't solve your problem, I suggest you post the code of your class, as Eitan suggested.

As for your other questions:
- Nested indexes can be either BASIC or EXTENDED, same as plain indexes.
- The syntax is correct, assuming the annotated property has properties called firstName and lastName (since its probably an ArrayList, that explains your exception).
- You don't have to implement equals or hashCode on the pojo class. GigaSpaces uses the value of the nested property for matching and indexing. The value's class should implement equals and hashcode. Since those values are usually java types (e.g. firstName and lastName are probably Strings) you usually don't have to worry about it, unless you're indexing a value whose type is a user defined class.

Niv Ingberg

answered 2010-06-11 02:23:47 -0500

niv gravatar image
edit flag offensive delete link more
0

What is the type of the property that you put the SpaceIndexes annotation over? Could you post the full class code?

Eitan

answered 2010-06-10 13:20:15 -0500

eitany gravatar image
edit flag offensive delete link more

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-06-10 13:04:04 -0500

Seen: 106 times

Last updated: Jun 11 '10