onKey() seems to break when using useIndex()

14 views
Skip to first unread message

Jens Teglhus Møller

unread,
Dec 8, 2022, 10:16:28 AM12/8/22
to jOOQ User Group
Hi

I just ran into a join query that broken when I added .useIndex("index) on the table.

create.select().from(TBL_A).join(TBL_B).onKey() 

works but when adding useIndex("idx_tbl_a_myidx"):

create.select().from(TBL_A.useIndex("idx_tbl_a_myidx")).join(TBL_B).onKey()

it fails with the following stacktrace:

org.jooq.exception.DataAccessException: No matching Key found between tables ["tbl_a" use index ("idx_tbl_a_myidx")] and ["tbl_b"]
    at org.jooq.impl.JoinTable.onKeyException(JoinTable.java:775) ~[jooq-3.16.11.jar:na]
    at org.jooq.impl.JoinTable.onKey(JoinTable.java:695) ~[jooq-3.16.11.jar:na]
    at org.jooq.impl.JoinTable.onKey(JoinTable.java:151) ~[jooq-3.16.11.jar:na]
    at org.jooq.impl.SelectQueryImpl.addJoinOnKey(SelectQueryImpl.java:4388) ~[jooq-3.16.11.jar:na]
    at org.jooq.impl.SelectImpl.onKey(SelectImpl.java:2196) ~[jooq-3.16.11.jar:na]
    at org.jooq.impl.SelectImpl.onKey(SelectImpl.java:143) ~[jooq-3.16.11.jar:na]


It seems like the HintedTable that is created loses its key information or perhaps it is because the tables is aliased (indirectly by the index hint).

Is this a know limitation or should I create an issue?

This is jooq on 3.16.11.

Best regards Jens

Lukas Eder

unread,
Dec 8, 2022, 10:41:40 AM12/8/22
to jooq...@googlegroups.com
Thanks for your report, Jens,

I don't think this has been a known issue so far, so yes, please, can you create one here:

Best Regards,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/3b0b5315-a646-4a80-b042-83f7bc38b42an%40googlegroups.com.

Jens Teglhus Møller

unread,
Dec 9, 2022, 5:19:33 AM12/9/22
to jOOQ User Group
Reply all
Reply to author
Forward
0 new messages