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

Ask Your Question

Space Read Operation with Id

What I need to do is:

1) Read the entry/POJO from space with MAXIMUM id , where id is a field/property in POJO. In this case I assume that the MAXIMUM id is the one which is the latest entry in space. 2) Read further entries/POJO from space based on id.

Any help will be appreciated with code snippets.



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

asked 2009-09-21 06:35:04 -0600

abhilash428 gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

The simplest option would be to use readMultiple + SQLQuery + order by. This means you will have to place some timestamp within your entry. Make sure the read operation will NOT use a template that running in FIFO mode since this might return strange results.

Other option would be to use take + FIFO. This means the object will be removed from the space.

Third option would be to use GSIterator in FIFO mode. This will fetch the existing entries first and later trigger a listener in FIFO order.


answered 2009-09-21 06:44:00 -0600

shay hassidim gravatar image
edit flag offensive delete link more


Can I use some thing like this?

SQLQuery<GridEntry> query = new SQLQuery<GridEntry>(GridEntry.class.getName() ,"max(id)");
GridEntry entry = space.read(query);

Do you support max function?

I want to read only one entry which has max id.

abhilash428 gravatar image abhilash428  ( 2009-09-21 06:55:01 -0600 )edit

You will need to use the JDBC API if you want to use the max function.
I’m not sure what do you mean read the entry which got max ID. Do you assign the object ID yourself? Do you use the @SpaceID ?

shay hassidim gravatar image shay hassidim  ( 2009-09-21 08:58:01 -0600 )edit

The id is generated by ourselves. The id is just another property in the POJO. It is an Integer value. We need to read only one entry which has the maximum id value.

abhilash428 gravatar image abhilash428  ( 2009-09-21 10:02:20 -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


Asked: 2009-09-21 06:35:04 -0600

Seen: 95 times

Last updated: Sep 21 '09