I have the SQL like:
select *
from some_table
where (select array(select unnest(first_array_field) except select unnest(second_array_field))) @> '{some_value}';
This is my try to write the where
condition for that query in a JOOQ way:
private Condition selectAwayValue(
List<Long> list) {
var allSelect = dslContext
.select(TABLE.ARRAY_1)
.from(DSL.unnest(TABLE.ARRAY_1));
var homeSelect = dslContext
.select(TABLE.ARRAY_2)
.from(DSL.unnest(TABLE.ARRAY_2));
var awaySelect = allSelect.except(homeSelect);
var awayArray = dslContext.select(DSL.array(awaySelect));
return awayArray.asField().contains(awayCompetitorIdsList);
}
I'm facing 2 problems here:
- I got the different SQL than I expected (see above)
- Also got the exception like
Cannot convert from 5 (class java.lang.Long) to class [Ljava.lang.Long;
I understand what's the exceptions says to me, but don't understand why :)
What's would be the best way to write my SQL in a jooq syntax?
I'm using the latest stable jooq version, the latest stable Postgres version
thanks