Summary: How to query the Space using entry ID
OverviewThe GigaSpaces API offers a variety of methods for querying the Space to retrieve data including SqlQuery and Template Matching. In the event that we know the exact ID value of the object being queried, GigaSpaces provides a faster solution of ID-based queries. Reading an Entry By IDIn order to access an object using its ID for Read and Take operations, the objects ID field must be specified. You can specify it via SpaceId (autogenerate=false) annotation: [SpaceID(AutoGenerate=false)] public String EmployeeID { get { return employeeID; } } To read the object back from the space using its ID and the ReadById operation: ISpaceProxy proxy; Employee myEmployee = proxy.ReadById<Employee>(new Object [] {"MyEmployeeObject" } , EmployeeID , routingValue); Reading Multiple Entries by IDsThe following shows how to read multiple objects using their IDs: ISpaceProxy proxy; // Initialize an ids array int[] ids = new Integer[] { ... }; // Set a routing key value (not mandatory but more efficient) int routingKey = ...; // Read objects from space IReadByIdsResult<Employee> result = proxy.ReadByIds<Employee>(new Object [] {"MyEmployeeObject" } , ids, routingKey); // Loop through results foreach (Employee employee in result) { // ... }
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |