1

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); 
  • これにより、ニューヨークに住むすべての従業員が検索されます。GridGain 内でこれを実装する可能性はありますか? もしそうなら、どのようにアドバイスできますか?この操作を実行するためにSQL結合を検討していましたが、実行時にそのようなクエリを作成する必要があり、常にWhere句の後にさまざまな量のパラメーターを使用する必要があります...そしてこれを解決できません。

ヘルプ/ヒントに感謝します。

ピーター

4

1 に答える 1

1

次のようなものを使用できます。

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");
于 2014-04-10T12:50:00.287 に答える