@SuppressWarnings("unchecked") private /* non-final */ Condition equal(Field<?>[] pk, Collection<T> ids) { if (pk.length == 1) { if (ids.size() == 1) { return equal(pk, ids.iterator().next()); } else { return ((Field<Object>) pk[0]).in(pk[0].getDataType().convert(ids)); } } // [#2573] Composite key T types are of type Record[N] else { return row(pk).in(ids.toArray(EMPTY_RECORD)); } }
@SuppressWarnings("unchecked") protected Condition equalKeys(Collection<T> ids){ UniqueKey<?> uk = getTable().getPrimaryKey(); Objects.requireNonNull(uk,()->"No primary key"); /** * Copied from jOOQs DAOImpl#equal-method */ TableField<? extends Record, ?>[] pk = uk.getFieldsArray(); Condition condition; if (pk.length == 1) { if (ids.size() == 1) { condition = equalKey(ids.iterator().next()); }else { condition = pk[0].in(pk[0].getDataType().convert(ids)); } }else { condition = row(pk).in(ids.toArray(new Record[ids.size()])); } return condition; }
@SuppressWarnings("unchecked") protected Condition equalKeys(Collection<T> ids){ UniqueKey<?> uk = getTable().getPrimaryKey(); Objects.requireNonNull(uk,()->"No primary key"); /** * Copied from jOOQs DAOImpl#equal-method */ TableField<? extends Record, ?>[] pk = uk.getFieldsArray(); Condition condition; if (pk.length == 1) { if (ids.size() == 1) { condition = equalKey(ids.iterator().next()); }else { condition = pk[0].in(pk[0].getDataType().convert(ids)); } }else { condition = row(pk).in(ids.toArray(new Record[ids.size()])); } return condition; }
/** * Do the actual fetching */ @SuppressWarnings("unchecked") private static <R1 extends Record, R2 extends Record> Result<R1> fetch( Collection<? extends R2> records, Table<R1> table, TableField<R1, ?>[] fields1, TableField<R2, ?>[] fields2) { // Use regular predicates if (fields1.length == 1) { return extractDSLContext(records) .selectFrom(table) .where(((Field<Object>) fields1[0]).in(extractValues(records, fields2[0]))) .fetch(); } // Use row value expressions else { return extractDSLContext(records) .selectFrom(table) .where(row(fields1).in(extractRows(records, fields2))) .fetch(); } }
/** * Do the actual fetching */ @SuppressWarnings("unchecked") private static <R1 extends Record, R2 extends Record> Result<R1> fetch( Collection<? extends R2> records, Table<R1> table, TableField<R1, ?>[] fields1, TableField<R2, ?>[] fields2) { // Use regular predicates if (fields1.length == 1) { return extractDSLContext(records) .selectFrom(table) .where(((Field<Object>) fields1[0]).in(extractValues(records, fields2[0]))) .fetch(); } // Use row value expressions else { return extractDSLContext(records) .selectFrom(table) .where(row(fields1).in(extractRows(records, fields2))) .fetch(); } }