jOOQ with java 15: both interface org.jooq.Record in org.jooq and class java.lang.Record in java.lang match
Asked Answered
L

2

5

I've just tried upgrading my project to Java 15, and now I get the following error:

  both interface org.jooq.Record in org.jooq and class java.lang.Record in java.lang match

Does anybody have some experience resolving this issue?

Leslileslie answered 17/9, 2020 at 12:57 Comment(2)
Use import org.jooq.Record; instead of just import org.jooq.*;Erratic
You can track this issue here github.com/jOOQ/jOOQ/issues/9988Roseleeroselia
H
10

In addition to what Aniket already said:

Import-on-demand no longer works for Record

The recommendation is to add an explicit import to your import-on-demand statement:

import org.jooq.*;
import org.jooq.Record;

Or to stop using import-on-demand entirely. E.g. in Eclipse, you can use the "Organize Imports" feature to expand all your import-on-demand statements to explicit imports, depending on the types you're actually using.

Using type inference

Another way to prevent this problem if it happens with local variables is to use var:

var record = ctx.fetchOne(TABLE, TABLE.ID.eq(1));

Now you don't have to import the type. This doesn't work with member types, method parameter and return types, of course.

We'll try to better document this: https://github.com/jOOQ/jOOQ/issues/10646

Hoberthobey answered 18/9, 2020 at 7:16 Comment(0)
R
6

Java 14 introduced records. java.lang.Record is a superclass of record which is conflicting with org.jooq.Record since every type in java.lang is auto imported. There are two solutions:

  1. Use a fully qualified name instead of Record and remove the import. Eg: org.jooq.Record instead of Record. (Don't forget to remove the import statement).
  2. Redeclare the org.jooq.Record to something specific. (Which I believe is not possible in your case as it's a third-party library.)
Roseleeroselia answered 17/9, 2020 at 13:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.