Search code examples
javaindexingjackcess

using multicolumn index in Jackcess to match on first column


I use Jackcess 2.1.5 to read data from an Access 2003 table having a multi-column index on colA and colB. This works fine given a value for colA and colB.

Now in theory such an index can be used to get all the rows matching a value for colA only. But how to do this with Jackcess? I cannot get it to work by using newEntryIterable or EntryIterableBuilder

Table table = access.getTable("tbl");
Index index = table.getIndex("index"); //index spanning two columns
IndexCursor cursor = CursorBuilder.createCursor(index);
for (Row row : cursor.newEntryIterable(val)) { //error: missing argument
for (Row row : cursor.newEntryIterable(val, null)) { //returns rows where colB == null
    //some code
}

Currently I have another index covering colA only. Is this the only solution?


Solution

  • I know this is a little late, but I wanted to add an update. As of the 2.1.7 release, Jackcess now supports partial index lookups. So, from the original question, this line will now work for finding all entries which match on the first column of the two-column index:

    for (Row row : cursor.newEntryIterable(val)) {