[jOOQ/jOOQ#15807] Added QOM API implementation

This commit is contained in:
Lukas Eder 2023-11-08 14:54:21 +01:00
parent ae88db710d
commit ba1820d09f
22 changed files with 205 additions and 89 deletions

View File

@ -90,6 +90,7 @@ import java.util.function.Function;
import org.jooq.TableOptions.TableType;
import org.jooq.conf.Settings;
import org.jooq.impl.DSL;
import org.jooq.impl.QOM.JoinHint;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -1008,7 +1009,7 @@ extends
// -------------------------------------------------------------------------
/**
* Join a table to this table using a {@link JoinType}
* Join a table to this table using a {@link JoinType}.
* <p>
* Depending on the <code>JoinType</code>, a subsequent
* {@link TableOnStep#on(Condition)} or
@ -1020,6 +1021,19 @@ extends
@Support
TableOptionalOnStep<Record> join(TableLike<?> table, JoinType type);
/**
* Join a table to this table using a {@link JoinType} and {@link JoinHint}.
* <p>
* Depending on the <code>JoinType</code>, a subsequent
* {@link TableOnStep#on(Condition)} or
* {@link TableOnStep#using(Field...)} clause is required. If it is required
* but omitted, a {@link DSL#trueCondition()}, i.e. <code>1 = 1</code>
* condition will be rendered
*/
@NotNull
@Support
TableOptionalOnStep<Record> join(TableLike<?> table, JoinType type, JoinHint hint);
/**
* <code>INNER JOIN</code> a table to this table.
* <p>

View File

@ -37,12 +37,12 @@
*/
package org.jooq;
import org.jetbrains.annotations.*;
// ...
// ...
import org.jooq.impl.DSL;
import org.jooq.impl.QOM.JoinHint;
import org.jetbrains.annotations.NotNull;
/**
* An intermediate type for the construction of a partitioned
@ -689,6 +689,17 @@ public interface TableOuterJoinStep<R extends Record> {

View File

@ -52,13 +52,13 @@ import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.SQL;
import org.jooq.Select;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.TableOnConditionStep;
import org.jooq.TableOptionalOnStep;
import org.jooq.TableOptions;
import org.jooq.TableOuterJoinStep;
import org.jooq.TablePartitionByStep;
import org.jooq.impl.QOM.JoinHint;
/**
* A base implementation for actual join tables and dummy join tables.
@ -249,4 +249,12 @@ implements
return (J) super.join(table, type);
}
// [#14906] Re-declare internal-type-returning method here, to prevent J
// from leaking into client code.
@SuppressWarnings("unchecked")
@Override
public final J join(TableLike<?> table, JoinType type, JoinHint hint) {
return (J) super.join(table, type, hint);
}
}

View File

@ -124,6 +124,7 @@ import org.jooq.UniqueKey;
// ...
import org.jooq.impl.QOM.Aliasable;
import org.jooq.impl.QOM.GenerationLocation;
import org.jooq.impl.QOM.JoinHint;
import org.jooq.tools.JooqLogger;
@ -1359,6 +1360,14 @@ implements
// this only internally, to prevent leaking JoinTable into client code
@Override
public /* non-final */ TableOptionalOnStep<Record> join(TableLike<?> table, JoinType type) {
return join(table, type, null);
}
// [#14906] Declare public API return type, allowing for JoinTable to override
// this only internally, to prevent leaking JoinTable into client code
@Override
public /* non-final */ TableOptionalOnStep<Record> join(TableLike<?> table, JoinType type, JoinHint hint) {
if (this instanceof NoTable)
return new NoTableJoin(table.asTable());
else if (this instanceof NoTableJoin n)
@ -1374,29 +1383,29 @@ implements
case CROSS_JOIN:
return new CrossJoin(this, table);
case FULL_OUTER_JOIN:
return new FullJoin(this, table);
return new FullJoin(this, table, hint);
case JOIN:
return new Join(this, table);
return new Join(this, table, hint);
case LEFT_ANTI_JOIN:
return new LeftAntiJoin(this, table);
case LEFT_OUTER_JOIN:
return new LeftJoin(this, table);
return new LeftJoin(this, table, hint);
case LEFT_SEMI_JOIN:
return new LeftSemiJoin(this, table);
case NATURAL_FULL_OUTER_JOIN:
return new NaturalFullJoin(this, table);
return new NaturalFullJoin(this, table, hint);
case NATURAL_JOIN:
return new NaturalJoin(this, table);
return new NaturalJoin(this, table, hint);
case NATURAL_LEFT_OUTER_JOIN:
return new NaturalLeftJoin(this, table);
return new NaturalLeftJoin(this, table, hint);
case NATURAL_RIGHT_OUTER_JOIN:
return new NaturalRightJoin(this, table);
return new NaturalRightJoin(this, table, hint);
case OUTER_APPLY:
return new OuterApply(this, table);
case RIGHT_OUTER_JOIN:
return new RightJoin(this, table);
return new RightJoin(this, table, hint);
case STRAIGHT_JOIN:
return new StraightJoin(this, table);
return new StraightJoin(this, table, hint);
default:
throw new IllegalArgumentException("Unsupported join type: " + type);
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -57,7 +58,7 @@ implements
{
CrossApply(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.CROSS_APPLY);
super(lhs, rhs, JoinType.CROSS_APPLY, null);
}
// -------------------------------------------------------------------------
@ -71,7 +72,8 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return new CrossApply(table1, table2);
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -57,7 +58,7 @@ implements
{
CrossJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.CROSS_JOIN);
super(lhs, rhs, JoinType.CROSS_JOIN, null);
}
// -------------------------------------------------------------------------
@ -71,7 +72,8 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return new CrossJoin(table1, table2);
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -56,12 +57,12 @@ implements
QOM.FullJoin<Record>
{
FullJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.FULL_OUTER_JOIN);
FullJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.FULL_OUTER_JOIN, hint);
}
FullJoin(TableLike<?> lhs, TableLike<?> rhs, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.FULL_OUTER_JOIN, lhsPartitionBy);
FullJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.FULL_OUTER_JOIN, hint, lhsPartitionBy);
}
// -------------------------------------------------------------------------
@ -75,10 +76,11 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return o != null
? new FullJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2).on(o)
: new FullJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2).using(u);
? new FullJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2).on(o)
: new FullJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2).using(u);
}
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -56,8 +57,8 @@ implements
QOM.Join<Record>
{
Join(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.JOIN);
Join(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.JOIN, hint);
}
// -------------------------------------------------------------------------
@ -71,8 +72,9 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return o != null ? new Join(table1, table2).on(o) : new Join(table1, table2).using(u);
return o != null ? new Join(table1, table2, h).on(o) : new Join(table1, table2, h).using(u);
}
}

View File

@ -140,6 +140,7 @@ import org.jooq.TableOptions;
// ...
import org.jooq.conf.RenderOptionalKeyword;
import org.jooq.exception.DataAccessException;
import org.jooq.impl.QOM.JoinHint;
import org.jooq.impl.QOM.Lateral;
import org.jooq.impl.QOM.UnmodifiableList;
@ -168,14 +169,15 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
final QueryPartList<Field<?>> rhsPartitionBy;
final JoinType type;
final JoinHint hint;
final ConditionProviderImpl condition;
final QueryPartList<Field<?>> using;
JoinTable(TableLike<?> lhs, TableLike<?> rhs, JoinType type) {
this(lhs, rhs, type, emptyList());
JoinTable(TableLike<?> lhs, TableLike<?> rhs, JoinType type, JoinHint hint) {
this(lhs, rhs, type, hint, emptyList());
}
JoinTable(TableLike<?> lhs, TableLike<?> rhs, JoinType type, Collection<? extends Field<?>> lhsPartitionBy) {
JoinTable(TableLike<?> lhs, TableLike<?> rhs, JoinType type, JoinHint hint, Collection<? extends Field<?>> lhsPartitionBy) {
super(TableOptions.expression(), N_JOIN);
this.lhs = lhs.asTable();
@ -183,6 +185,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
this.lhsPartitionBy = new QueryPartList<>(lhsPartitionBy);
this.rhsPartitionBy = new QueryPartList<>();
this.type = type;
this.hint = hint;
this.condition = new ConditionProviderImpl();
this.using = new QueryPartList<>();
}
@ -198,7 +201,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
if (lhs == newLhs && rhs == newRhs && condition == newCondition)
return (J) this;
return construct(newLhs, lhsPartitionBy, rhsPartitionBy, newRhs, newCondition, using);
return construct(newLhs, lhsPartitionBy, rhsPartitionBy, newRhs, newCondition, using, hint);
}
// ------------------------------------------------------------------------
@ -823,7 +826,8 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition on,
Collection<? extends Field<?>> using
Collection<? extends Field<?>> using,
JoinHint hint
);
public final Table<?> $table1() {
@ -831,7 +835,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
}
public final J $table1(Table<?> t1) {
return construct(t1, $partitionBy1(), $partitionBy2(), $table2(), $on(), $using());
return construct(t1, $partitionBy1(), $partitionBy2(), $table2(), $on(), $using(), $hint());
}
public final UnmodifiableList<Field<?>> $partitionBy1() {
@ -839,7 +843,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
}
public final J $partitionBy1(Collection<? extends Field<?>> p1) {
return construct($table1(), p1, $partitionBy2(), $table2(), $on(), $using());
return construct($table1(), p1, $partitionBy2(), $table2(), $on(), $using(), $hint());
}
public final UnmodifiableList<Field<?>> $partitionBy2() {
@ -847,7 +851,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
}
public final J $partitionBy2(Collection<? extends Field<?>> p2) {
return construct($table1(), $partitionBy1(), p2, $table2(), $on(), $using());
return construct($table1(), $partitionBy1(), p2, $table2(), $on(), $using(), $hint());
}
public final Table<?> $table2() {
@ -855,7 +859,15 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
}
public final J $table2(Table<?> t2) {
return construct($table1(), $partitionBy1(), $partitionBy2(), t2, $on(), $using());
return construct($table1(), $partitionBy1(), $partitionBy2(), t2, $on(), $using(), $hint());
}
public final JoinHint $hint() {
return hint;
}
public final J $hint(JoinHint newHint) {
return construct($table1(), $partitionBy1(), $partitionBy2(), $table2(), $on(), $using(), newHint);
}
public final Condition $on() {
@ -863,7 +875,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
}
public final J $on(Condition o) {
return construct($table1(), $partitionBy1(), $partitionBy2(), $table2(), o, emptyList());
return construct($table1(), $partitionBy1(), $partitionBy2(), $table2(), o, emptyList(), $hint());
}
public final UnmodifiableList<Field<?>> $using() {
@ -871,7 +883,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
}
public final J $using(Collection<? extends Field<?>> u) {
return construct($table1(), $partitionBy1(), $partitionBy2(), $table2(), null, u);
return construct($table1(), $partitionBy1(), $partitionBy2(), $table2(), null, u, $hint());
}
@ -903,6 +915,7 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -57,7 +58,7 @@ implements
{
LeftAntiJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.LEFT_ANTI_JOIN);
super(lhs, rhs, JoinType.LEFT_ANTI_JOIN, null);
}
// -------------------------------------------------------------------------
@ -71,7 +72,8 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return o != null ? new LeftAntiJoin(table1, table2).on(o) : new LeftAntiJoin(table1, table2).using(u);
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -56,12 +57,12 @@ implements
QOM.LeftJoin<Record>
{
LeftJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.LEFT_OUTER_JOIN);
LeftJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.LEFT_OUTER_JOIN, hint);
}
LeftJoin(TableLike<?> lhs, TableLike<?> rhs, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.LEFT_OUTER_JOIN, lhsPartitionBy);
LeftJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.LEFT_OUTER_JOIN, hint, lhsPartitionBy);
}
// -------------------------------------------------------------------------
@ -75,10 +76,11 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return o != null
? new LeftJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2).on(o)
: new LeftJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2).using(u);
? new LeftJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2).on(o)
: new LeftJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2).using(u);
}
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -57,7 +58,7 @@ implements
{
LeftSemiJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.LEFT_SEMI_JOIN);
super(lhs, rhs, JoinType.LEFT_SEMI_JOIN, null);
}
// -------------------------------------------------------------------------
@ -71,7 +72,8 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return o != null ? new LeftSemiJoin(table1, table2).on(o) : new LeftSemiJoin(table1, table2).using(u);
}

View File

@ -47,6 +47,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -58,12 +59,12 @@ implements
QOM.NaturalFullJoin<Record>
{
NaturalFullJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.NATURAL_FULL_OUTER_JOIN, emptyList());
NaturalFullJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.NATURAL_FULL_OUTER_JOIN, hint, emptyList());
}
NaturalFullJoin(TableLike<?> lhs, TableLike<?> rhs, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.NATURAL_FULL_OUTER_JOIN, lhsPartitionBy);
NaturalFullJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.NATURAL_FULL_OUTER_JOIN, hint, lhsPartitionBy);
}
// -------------------------------------------------------------------------
@ -77,8 +78,9 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return new NaturalFullJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2);
return new NaturalFullJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2);
}
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -56,8 +57,8 @@ implements
QOM.NaturalJoin<Record>
{
NaturalJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.NATURAL_JOIN);
NaturalJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.NATURAL_JOIN, hint);
}
// -------------------------------------------------------------------------
@ -71,8 +72,9 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return new NaturalJoin(table1, table2);
return new NaturalJoin(table1, table2, h);
}
}

View File

@ -47,6 +47,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -58,12 +59,12 @@ implements
QOM.NaturalLeftJoin<Record>
{
NaturalLeftJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.NATURAL_LEFT_OUTER_JOIN, emptyList());
NaturalLeftJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.NATURAL_LEFT_OUTER_JOIN, hint, emptyList());
}
NaturalLeftJoin(TableLike<?> lhs, TableLike<?> rhs, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.NATURAL_LEFT_OUTER_JOIN, lhsPartitionBy);
NaturalLeftJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.NATURAL_LEFT_OUTER_JOIN, hint, lhsPartitionBy);
}
// -------------------------------------------------------------------------
@ -77,8 +78,9 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return new NaturalLeftJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2);
return new NaturalLeftJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2);
}
}

View File

@ -47,6 +47,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -58,12 +59,12 @@ implements
QOM.NaturalRightJoin<Record>
{
NaturalRightJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.NATURAL_RIGHT_OUTER_JOIN, emptyList());
NaturalRightJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.NATURAL_RIGHT_OUTER_JOIN, hint, emptyList());
}
NaturalRightJoin(TableLike<?> lhs, TableLike<?> rhs, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.NATURAL_RIGHT_OUTER_JOIN, lhsPartitionBy);
NaturalRightJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.NATURAL_RIGHT_OUTER_JOIN, hint, lhsPartitionBy);
}
// -------------------------------------------------------------------------
@ -77,8 +78,9 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return new NaturalRightJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2);
return new NaturalRightJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2);
}
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -57,7 +58,7 @@ implements
{
OuterApply(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.OUTER_APPLY);
super(lhs, rhs, JoinType.OUTER_APPLY, null);
}
// -------------------------------------------------------------------------
@ -71,7 +72,8 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return new OuterApply(table1, table2);
}

View File

@ -55,6 +55,7 @@ import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.TableOuterJoinStep;
import org.jooq.TablePartitionByStep;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -305,6 +306,12 @@ final class PartitionJoinTable implements TableOuterJoinStep<Record> {

View File

@ -1041,8 +1041,10 @@ public final class QOM {
{
@NotNull Table<?> $table1();
@NotNull Table<?> $table2();
@Nullable JoinHint $hint();
@NotNull J $table1(Table<?> table1);
@NotNull J $table2(Table<?> table2);
@NotNull J $hint(JoinHint hint);
}
public sealed interface CrossJoin<R extends org.jooq.Record>
@ -6063,6 +6065,7 @@ public final class QOM {
/**
* The data type to try to cast the value to
*/
@Override
@NotNull default DataType<T> $dataType() { return $arg2(); }
/**
@ -8586,6 +8589,24 @@ public final class QOM {
}
}
/**
* The <code>JoinHint</code> type.
* <p>
* A hint for join algorithms.
*/
public enum JoinHint {
HASH(keyword("hash")),
LOOP(keyword("loop")),
MERGE(keyword("merge")),
;
final Keyword keyword;
private JoinHint(Keyword keyword) {
this.keyword = keyword;
}
}
// -------------------------------------------------------------------------

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -56,12 +57,12 @@ implements
QOM.RightJoin<Record>
{
RightJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.RIGHT_OUTER_JOIN);
RightJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.RIGHT_OUTER_JOIN, hint);
}
RightJoin(TableLike<?> lhs, TableLike<?> rhs, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.RIGHT_OUTER_JOIN, lhsPartitionBy);
RightJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint, Collection<? extends Field<?>> lhsPartitionBy) {
super(lhs, rhs, JoinType.RIGHT_OUTER_JOIN, hint, lhsPartitionBy);
}
// -------------------------------------------------------------------------
@ -75,10 +76,11 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return o != null
? new RightJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2).on(o)
: new RightJoin(table1, table2, partitionBy1).partitionBy0(partitionBy2).using(u);
? new RightJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2).on(o)
: new RightJoin(table1, table2, h, partitionBy1).partitionBy0(partitionBy2).using(u);
}
}

View File

@ -45,6 +45,7 @@ import org.jooq.JoinType;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.impl.QOM.JoinHint;
/**
* @author Lukas Eder
@ -56,8 +57,8 @@ implements
QOM.StraightJoin<Record>
{
StraightJoin(TableLike<?> lhs, TableLike<?> rhs) {
super(lhs, rhs, JoinType.STRAIGHT_JOIN);
StraightJoin(TableLike<?> lhs, TableLike<?> rhs, JoinHint hint) {
super(lhs, rhs, JoinType.STRAIGHT_JOIN, hint);
}
// -------------------------------------------------------------------------
@ -71,8 +72,9 @@ implements
Collection<? extends Field<?>> partitionBy2,
Table<?> table2,
Condition o,
Collection<? extends Field<?>> u
Collection<? extends Field<?>> u,
JoinHint h
) {
return o != null ? new StraightJoin(table1, table2).on(o) : new StraightJoin(table1, table2).using(u);
return o != null ? new StraightJoin(table1, table2, h).on(o) : new StraightJoin(table1, table2, h).using(u);
}
}

View File

@ -78,7 +78,6 @@ import org.jooq.ForeignKey;
import org.jooq.InverseForeignKey;
import org.jooq.JoinType;
import org.jooq.Name;
import org.jooq.Path;
// ...
import org.jooq.Record;
import org.jooq.Row;
@ -89,6 +88,7 @@ import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.TableOptionalOnStep;
import org.jooq.TableOptions;
import org.jooq.impl.QOM.JoinHint;
import org.jooq.impl.QOM.UEmpty;
import org.jooq.tools.StringUtils;
@ -327,9 +327,9 @@ implements
final Condition pathCondition() {
if (childPath != null)
return wrapForImplicitJoin(new Join(path, this).onKey(childPath).condition.getWhere());
return wrapForImplicitJoin(new Join(path, this, null).onKey(childPath).condition.getWhere());
else if (parentPath != null)
return wrapForImplicitJoin(new Join(this, path).onKey(parentPath.getForeignKey()).condition.getWhere());
return wrapForImplicitJoin(new Join(this, path, null).onKey(parentPath.getForeignKey()).condition.getWhere());
else
return noCondition();
}
@ -570,6 +570,11 @@ implements
return super.join(table, type);
}
@Override
public final TableOptionalOnStep<Record> join(TableLike<?> table, JoinType type, JoinHint hint) {
return super.join(table, type, hint);
}
// -------------------------------------------------------------------------
// XXX: FieldsTrait "undeprecations" for generated code
// -------------------------------------------------------------------------