Package com.kenshoo.jooq
Class SelectQueryExtender
- java.lang.Object
-
- com.kenshoo.jooq.SelectQueryExtender
-
public class SelectQueryExtender extends java.lang.ObjectProvides a convenient (and MySQL-friendly) way of solving the use-case of querying records by N-tuples of identifiers. The simplest case is querying by a list of IDs in which case it could be expressed with a simple IN. However in terms of performance (and logs) it's better to do a join with a temporary table populated with those IDs instead. This class does it automatically. In the more complicated case where the lookup is done by two fields (e.g. profile/affcode), it is impossible to express it with an IN condition and a temp table has to be used in this case. Example of simple usage:AdCriterias ac = AdCriterias.TABLE; SelectConditionStep<Record2<String, Integer>> query = dslContext.select(ac.affcode, ac.criteria_id) .from(ac).where(ac.profile_id.eq(profileId)); try (QueryExtension<SelectConditionStep<Record2<String, Integer>>> queryExtension = SelectQueryExtender.of(query).withCondition(ac.affcode).in(affcodes)) { return queryExtension.getQuery().fetchMap(ac.affcode, ac.criteria_id); }The returned object is a resource and it is crucial to place it inside try/finally block so it could be closed
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSelectQueryExtender.BuilderIn1<Q extends org.jooq.SelectFinalStep,T>static interfaceSelectQueryExtender.BuilderIn2<Q extends org.jooq.SelectFinalStep,T1,T2>static interfaceSelectQueryExtender.BuilderIn3<Q extends org.jooq.SelectFinalStep,T1,T2,T3>static interfaceSelectQueryExtender.BuilderIn4<Q extends org.jooq.SelectFinalStep,T1,T2,T3,T4>static interfaceSelectQueryExtender.BuilderIn5<Q extends org.jooq.SelectFinalStep,T1,T2,T3,T4,T5>static interfaceSelectQueryExtender.BuilderWith<Q extends org.jooq.SelectFinalStep>
-
Constructor Summary
Constructors Constructor Description SelectQueryExtender()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <Q extends org.jooq.SelectFinalStep>
SelectQueryExtender.BuilderWith<Q>of(org.jooq.DSLContext dslContext, Q query)static <Q extends org.jooq.SelectFinalStep>
QueryExtension<Q>of(org.jooq.DSLContext dslContext, Q query, java.util.List<FieldAndValues<?>> conditions)
-
-
-
Method Detail
-
of
public static <Q extends org.jooq.SelectFinalStep> QueryExtension<Q> of(org.jooq.DSLContext dslContext, Q query, java.util.List<FieldAndValues<?>> conditions)
-
of
public static <Q extends org.jooq.SelectFinalStep> SelectQueryExtender.BuilderWith<Q> of(org.jooq.DSLContext dslContext, Q query)
-
-