Hi Naveen,
Yes, you can get a whole key and value objects.
You need to do the following steps:
1. define a key and value types in the following way:
package com.ril.edif;
public class CityKey {
// Please make sure that the field, which is used as primary key,
annotated by AffinityKeyMapped,
// and uses upper case (it means that 'city_id' is not correct name)
@AffinityKeyMapped
private Long CITY_ID;
public CityKey(Long id) {
CITY_ID = id;
}
...
}
public class ValueType {
private String city_name;
private String state_name;
public ValueType(String city_name, String state_name) {
this.city_name = city_name;
this.state_name = state_name;
}
...
}
2. create 'city_table' and insert some value(s)
cache.query(new SqlFieldsQuery(
"CREATE TABLE city_details (city_id LONG PRIMARY KEY, city_name
VARCHAR, state_name VARCHAR) WITH \"" +
"cache_name=city_details, " +
"key_type=com.ril.edif.KeyType, " +
"value_type=com.ril.edif.ValueType\""));
SqlFieldsQuery query = new SqlFieldsQuery("INSERT INTO city_details
(city_id, city_name, state_name) VALUES (?, ?, ?)");
query.setArgs(1L, "Forest Hill", "California");
cache.query(query).getAll();
3. and final step
IgniteCache<KeyType, ValueType> cache = ignite.cache("city_details");
ValueType value = cache.get(new KeyType(1));
Thanks!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/