有没有人知道是否有可能用GridGain实现存储在内存数据网格中的对象的模板搜索?让我们考虑以下几点。你有这样的课程:
class Employee{
private Long id;
private String name;
private Address address;
private Account account;
}
class Account{
private Long id;
private String accountNr;
}
class Address{
private String street;
private String postcode;
private String city;
private Country country;
}然后就有了这样的搜索模板:
Address address = new Address(null, null, "New York", null);
Employee template = new Employee(null, null,address, null);
grid.read(template); 我将感谢任何帮助/暗示。
彼得
发布于 2014-04-10 12:50:00
你可以使用这样的东西:
public class Address {
@GridCacheQuerySqlField(unique = true)
private long id;
@GridCacheQuerySqlField
private String street;
@GridCacheQuerySqlField
private String postcode;
@GridCacheQuerySqlField
private String city;
@GridCacheQuerySqlField
private Country country;
}
public class Employee {
@GridCacheQuerySqlField(unique=true)
private long id;
@GridCacheQuerySqlField
private long addressId; // Address ID.
// Not indexed.
private String name;
}然后执行以下查询:
GridCacheQuery<Map.Entry<Long, Employee>> qry = cache.queries().createSqlQuery(Employee.class,
"from Employee, Address where Employee.addressId = Address.id " +
"and Address.name = ?");
// Query all nodes to find all cached CompanyZ employees in New York
qry.execute("CompanyZ","New York");https://stackoverflow.com/questions/22987403
复制相似问题