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

Ask Your Question

dynamic properties in nested objects


I need an object graph as follows:

class Parent contains an object of type Child. class Child contains a list of objects of type Data. class Data contains a DocumentProperties property which needs to act as a SpaceDynamicProperties

I will query the objects this way:

from Parent where child.dataList[].someKey='foo' from Parent where child.dataList[].someOtherKey='bar'


@SpaceClass public class Parent {

String id; Child child;

@SpaceID public String getId()...

@SpaceProperty @SpaceIndexes({@SpaceIndex(path = "dataList[].someKey", type = SpaceIndexType.EXTENDED), @SpaceIndex(path = "dataList[].someOtherKey", type = SpaceIndexType.BASIC)}) public Child getChild()...


public class Child{

List<data> dataList;

public List<data> getDataList()... }

public class Data{ DocumentProperties dataMap;

public DocumentProperties getDataMap()...


my question is: do I have to annotate getDataMap() in class Data with @SpaceDynamicProperties? If so, do I have to annotate Child and Data with @SpaceClass and define a @SpaceID for each? Otherwise, where should I place the @SpaceDynamicProperties annotation?

thank you very much for your help.

Kind Regards,


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

asked 2013-02-18 09:26:18 -0500

rdavidovich gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted


SpaceDynamicProperties are only relevant as first level property of the pojo which is written to the space. The nested objects, in your case Child class, should not have any @Space annotation on them since they are not written as isolated space objects but exists only inside another space class object.

So the answer to your question is no, you don't need to annotate the Data and Child classes at all.


answered 2013-02-19 07:47:37 -0500

eitany gravatar image
edit flag offensive delete link more


Hi eitan,

thank you for your answer.

so to clarify, will the DocumentProperties property in the Data class will act as dynamic properties and be queried as such without any annotation at all? or Dynamic properties in nested objects are not supported?

Kind Regards,


rdavidovich gravatar imagerdavidovich ( 2013-02-19 10:44:40 -0500 )edit

DocumentProperties is just a Map<string,object> implementation which has a lighter serialization for the string keys if you use repetitive keys (not values) in the map. If your keys are not repetitive and the unique set of keys size is not bounded it is not recommended to use it.

So the answer is yes, you can use it, but only use it for the right reason. If you do not have a bounded set of keys, use regular or other Map<string,object> implementation.


eitany gravatar imageeitany ( 2013-02-20 02:12:15 -0500 )edit

Hi Eitan,

in fact my question is not about the DocumentProperties class itself, but about having a map annotated with @SpaceDynamicProperties inside a nested object, so I can query it's contents as actual properties of the object.

in my case, I need to have this behavior in the Data class, because I need to query the grid as follows:

from Parent where child.dataList.someKey.someProperty='foo'
from Parent where child.dataList.someOtherKey.someOtherProperty='bar

I already use @SpaceDynamicProperties successfully, but at the Parent level, so my question is if this can be achieved two levels lower.

to make it clearer, in one hand I have a MarketData objects hierarchy (Deposit, BasisSwap, CCS...) which are inserted regularly in the grid. In the other hand I have a CalculationDescriptor which contains a list of DataDescriptor, and each DataDescriptor contains one or several MarketData 'sample' objects.
As MarketData objects are inserted, I need to find all the CalculationDescriptor that contain them in their DataDescriptors to do some processing.

For example, I have a USD 3M Deposit that is inserted in the grid, so I need to find all the CalculationDescriptor containing a 3M USD Deposit in any of their DataDescriptors:

from CalculationDescriptor where dataDescriptors.deposit.currency=USD and dataDescriptors.deposit.maturity=3M

next I have a EUR/USD 6M CCS inserted in the grid, so again, I need to find the related data:

from CalculationDescriptor where dataDescriptors.ccs.baseCurrency=USD and dataDescriptors.ccs.crossCurrency=EUR and dataDescriptors.ccs.maturity=6M

perhaps there is a more effective way of achieving this?

thank you for your help.

Kind Regards,


rdavidovich gravatar imagerdavidovich ( 2013-02-20 03:36:34 -0500 )edit


You can use this syntax to query any Map<string,object> property of a class at any level. It doesn't have to be marked as @SpaceDynamicProperties. You are mixing two different topics, The dynamic properties is more designed for interopariblity with SpaceDocument where dynamic properties are a key capability and you don't have all the schema declared as static and you still need to read it as pojo. You can query a map property and index it without marking it as dynamic property.

That said, the syntax you are trying to query may not give you what you want.

from CalculationDescriptor where dataDescriptors[].deposit.currency=USD and dataDescriptors[].deposit.maturity=3M

Means that the dataDescriptors collection should contain some deposit element where has currency=USD and it should contain some deposit maturity=3M. Notice it is not have to be the same deposit element. There is no syntax to create such a query where the element matched in all the statements inside the query has to be the same element.

If that is what you are trying to achieve you will need to write a custom SpaceTask which will run on the space and first execute from CalculationDescriptor where dataDescriptors[*].deposit.currency=USD, this should return all the CalculationDescriptor that has a deposit of USD, and the SpaceTask should scan all the returned elements and return only the CalculationDescriptor that contains a deposit element that has both currency=USD and maturity=3M.


eitany gravatar imageeitany ( 2013-02-20 04:45:24 -0500 )edit

Hi Eitan,

thank you very much for your answer, it's much clearer now.

Kind Regards,


rdavidovich gravatar imagerdavidovich ( 2013-02-20 06:42:16 -0500 )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


Asked: 2013-02-18 09:26:18 -0500

Seen: 96 times

Last updated: Feb 19 '13