Hi,

As per this link (
https://stackoverflow.com/questions/36773011/what-is-the-difference-between-a-primary-key-and-a-surrogate-key),
I have created the QueryEntities as follows. I have not set the fields and
indexes explicitly as it is already define in my value Pojo class.

private static QueryEntity createIPV4RangeDataEntity() {
    QueryEntity ipV4RangeDataEntity = new QueryEntity();
    ipV4RangeDataEntity.setValueType(IPV4RangeData.class.getName());
    ipV4RangeDataEntity.setKeyType(IPRangeDataKey.class.getName());
    return ipV4RangeDataEntity;
}

I am using following code to get the number of records for a given groupId.

try (QueryCursor<List<?>> cursor = ipV4RangeDataCache.query(new
SqlFieldsQuery("select count(1) from IPV4RANGEDATA where assetGroupId
= 10")) )  {
    for (List<?> row : cursor)
        System.out.println("count=" + row.get(0));
}

But when execute above code, I get following exception. Do I have to
redefine all the fields,qury fields and indexes in QueryEntity for each
cache? Can some one please advise?

 Caused by: org.h2.jdbc.JdbcSQLException: Column "GROUPID" not found; SQL
statement:
select count(1) from IPV4RANGEDATA where groupId = 10 [42122-196]


Pojo:

public class IPV4RangeData implements Serializable {

    private long id;

    @QuerySqlField(orderedGroups = {@QuerySqlField.Group(name =
"ipv4_range_idx", order = 0)})
    private long groupId;

    private int assetType;

    @QuerySqlField(orderedGroups = {@QuerySqlField.Group(name =
"ipv4_range_idx", order = 1)})
    private long startIp;

    @QuerySqlField(orderedGroups = {@QuerySqlField.Group(name =
"ipv4_range_idx", order = 1)})
    private long endIp;






Thanks,
Prasad

Reply via email to