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

Ask Your Question

autogenerated space ids

I'm trying to use a SpaceId field with the autogenerate flag set, and having some issues.

When I try to write an object of this class into the space, I get this exception:

"Caused by: java.lang.RuntimeException: Class: Foo, operation: write , load-balancing: hash-based, Broadcast mode: BROADCAST_IF_NULL_VALUES , problem: NULL value in indexed field 'spaceID' is not permitted."

Isn't the point of the autogenerated space ids that an id will automatically be injected into the field when it's written to the space? So why is it NULL? What's the problem?

Also, I'm not getting this exception when I run in Eclipse with an IntegratedProcessingUnitContainer, only if I deploy to a GSC.

Ironically, earlier I was getting an exception when I tried to write an object with an autogenerated ID into the space complaining that the id field was not NULL. This occurred when I read the object from the space, then tried to write it back using the UPDATE_ONLY modifier. If the autogenerated id field must be null for any write operation, does that mean an object with an autogenerated ID cannot be updated?

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

asked 2008-01-31 17:32:56 -0500

ryryguy's avatar

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

jaissefsfex's avatar
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

When performing write operations into a partitioned space your routing field must have a value. It can?t be NULL.
When performing read/take with timeout > 0 you must have a value as part of your routing field. We do not support blocking operations in broadcast mode (i.e. routing field is NULL).
Update Operations requires the SpaceID to be set.

Any chance your routing field is same as your SpaceID field ?
Can you have different fields used for the SpaceID and Routing field?


answered 2008-01-31 17:43:18 -0500

shay hassidim's avatar
edit flag offensive delete link more


The routing field was not supposed to be the same as my space id field... but I had neglected to put the SpaceRouting decoration on the other field. =0 So I guess in that case it chose the SpaceID field to be the routing field? Ooops

On the other question, of trying to update an object with autogenerated space ID, you say "Update Operations requires the SpaceID to be set." But then it seems the autogenerated id logic requires it to be not set. So such objects just can't be updated then - they're basically "write once"?

ryryguy's avatar ryryguy  ( 2008-01-31 17:55:47 -0500 )edit

A POJO based class by default using the UpdateModifiers.UPDATE_OR_WRITE when IJSpace.write operations called. The Entry based class working differently ? it is using the UpdateModifiers.WRITE_ONLY mode when IJSpace.write operations called.

UpdateModifiers.WRITE_ONLY means inserting new entry into the space. UpdateModifiers.UPDATE_OR_WRITE means updating the entry in case such with the same UID already exists within the space. In this case ? you must have a UID as part of your object that will be based on a field value.

I guess you will agree there is no sense to support Update when the UID is automatically generated. In fact in this case ? you must have the SpaceID field empty to allow the client runtime to place the generated UID back into this field. After the write operation this field will store the generated UID.

We have chosen this behavior to allow users to use the same method call for write and update operations for POJO objects. We could not do that for Entry based classes since this would violet the JavaSpace specification.

Still ? there are cases , such as optimistic locking where POJO users should call explicitly the IJSpace.update operation to get the EntryVersionConflictException.


shay hassidim's avatar shay hassidim  ( 2008-02-01 13:43:08 -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: 2008-01-31 17:32:56 -0500

Seen: 253 times

Last updated: Jan 31 '08