org.jooq.impl.MergeImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of payment-retries-plugin Show documentation
Show all versions of payment-retries-plugin Show documentation
Kill Bill Payment Retries plugin
The newest version!
/*
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.Clause.MERGE;
import static org.jooq.Clause.MERGE_DELETE_WHERE;
import static org.jooq.Clause.MERGE_MERGE_INTO;
import static org.jooq.Clause.MERGE_ON;
import static org.jooq.Clause.MERGE_SET;
import static org.jooq.Clause.MERGE_SET_ASSIGNMENT;
import static org.jooq.Clause.MERGE_USING;
import static org.jooq.Clause.MERGE_VALUES;
import static org.jooq.Clause.MERGE_WHEN_MATCHED_THEN_UPDATE;
import static org.jooq.Clause.MERGE_WHEN_NOT_MATCHED_THEN_INSERT;
import static org.jooq.Clause.MERGE_WHERE;
// ...
import static org.jooq.impl.DSL.condition;
import static org.jooq.impl.DSL.exists;
import static org.jooq.impl.DSL.insertInto;
import static org.jooq.impl.DSL.notExists;
import static org.jooq.impl.DSL.nullSafe;
import static org.jooq.impl.Tools.EMPTY_FIELD;
import static org.jooq.impl.Tools.DataKey.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Generated;
import org.jooq.Clause;
import org.jooq.Condition;
import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.MergeKeyStep1;
import org.jooq.MergeKeyStep10;
import org.jooq.MergeKeyStep11;
import org.jooq.MergeKeyStep12;
import org.jooq.MergeKeyStep13;
import org.jooq.MergeKeyStep14;
import org.jooq.MergeKeyStep15;
import org.jooq.MergeKeyStep16;
import org.jooq.MergeKeyStep17;
import org.jooq.MergeKeyStep18;
import org.jooq.MergeKeyStep19;
import org.jooq.MergeKeyStep2;
import org.jooq.MergeKeyStep20;
import org.jooq.MergeKeyStep21;
import org.jooq.MergeKeyStep22;
import org.jooq.MergeKeyStep3;
import org.jooq.MergeKeyStep4;
import org.jooq.MergeKeyStep5;
import org.jooq.MergeKeyStep6;
import org.jooq.MergeKeyStep7;
import org.jooq.MergeKeyStep8;
import org.jooq.MergeKeyStep9;
import org.jooq.MergeMatchedDeleteStep;
import org.jooq.MergeMatchedSetMoreStep;
import org.jooq.MergeNotMatchedSetMoreStep;
import org.jooq.MergeNotMatchedValuesStep1;
import org.jooq.MergeNotMatchedValuesStep10;
import org.jooq.MergeNotMatchedValuesStep11;
import org.jooq.MergeNotMatchedValuesStep12;
import org.jooq.MergeNotMatchedValuesStep13;
import org.jooq.MergeNotMatchedValuesStep14;
import org.jooq.MergeNotMatchedValuesStep15;
import org.jooq.MergeNotMatchedValuesStep16;
import org.jooq.MergeNotMatchedValuesStep17;
import org.jooq.MergeNotMatchedValuesStep18;
import org.jooq.MergeNotMatchedValuesStep19;
import org.jooq.MergeNotMatchedValuesStep2;
import org.jooq.MergeNotMatchedValuesStep20;
import org.jooq.MergeNotMatchedValuesStep21;
import org.jooq.MergeNotMatchedValuesStep22;
import org.jooq.MergeNotMatchedValuesStep3;
import org.jooq.MergeNotMatchedValuesStep4;
import org.jooq.MergeNotMatchedValuesStep5;
import org.jooq.MergeNotMatchedValuesStep6;
import org.jooq.MergeNotMatchedValuesStep7;
import org.jooq.MergeNotMatchedValuesStep8;
import org.jooq.MergeNotMatchedValuesStep9;
import org.jooq.MergeNotMatchedValuesStepN;
import org.jooq.MergeOnConditionStep;
import org.jooq.MergeOnStep;
import org.jooq.MergeUsingStep;
import org.jooq.Operator;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Row;
import org.jooq.SQL;
import org.jooq.Select;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.UniqueKey;
import org.jooq.tools.StringUtils;
/**
* The SQL standard MERGE statement
*
* @author Lukas Eder
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
final class MergeImpl extends AbstractQuery
implements
// Cascading interface implementations for Merge behaviour
MergeUsingStep,
// [jooq-tools] START [implementsKeyStep]
MergeKeyStep1,
MergeKeyStep2,
MergeKeyStep3,
MergeKeyStep4,
MergeKeyStep5,
MergeKeyStep6,
MergeKeyStep7,
MergeKeyStep8,
MergeKeyStep9,
MergeKeyStep10,
MergeKeyStep11,
MergeKeyStep12,
MergeKeyStep13,
MergeKeyStep14,
MergeKeyStep15,
MergeKeyStep16,
MergeKeyStep17,
MergeKeyStep18,
MergeKeyStep19,
MergeKeyStep20,
MergeKeyStep21,
MergeKeyStep22,
// [jooq-tools] END [implementsKeyStep]
MergeOnStep,
MergeOnConditionStep,
MergeMatchedSetMoreStep,
MergeMatchedDeleteStep,
MergeNotMatchedSetMoreStep,
// [jooq-tools] START [implementsNotMatchedValuesStep]
MergeNotMatchedValuesStep1,
MergeNotMatchedValuesStep2,
MergeNotMatchedValuesStep3,
MergeNotMatchedValuesStep4,
MergeNotMatchedValuesStep5,
MergeNotMatchedValuesStep6,
MergeNotMatchedValuesStep7,
MergeNotMatchedValuesStep8,
MergeNotMatchedValuesStep9,
MergeNotMatchedValuesStep10,
MergeNotMatchedValuesStep11,
MergeNotMatchedValuesStep12,
MergeNotMatchedValuesStep13,
MergeNotMatchedValuesStep14,
MergeNotMatchedValuesStep15,
MergeNotMatchedValuesStep16,
MergeNotMatchedValuesStep17,
MergeNotMatchedValuesStep18,
MergeNotMatchedValuesStep19,
MergeNotMatchedValuesStep20,
MergeNotMatchedValuesStep21,
MergeNotMatchedValuesStep22,
// [jooq-tools] END [implementsNotMatchedValuesStep]
MergeNotMatchedValuesStepN {
/**
* Generated UID
*/
private static final long serialVersionUID = -8835479296876774391L;
private static final Clause[] CLAUSES = { MERGE };
private final WithImpl with;
private final Table table;
private final ConditionProviderImpl on;
private TableLike> using;
// [#998] Oracle extensions to the MERGE statement
private Condition matchedWhere;
private Condition matchedDeleteWhere;
private Condition notMatchedWhere;
// Flags to keep track of DSL object creation state
private boolean matchedClause;
private FieldMapForUpdate matchedUpdate;
private boolean notMatchedClause;
private FieldMapForInsert notMatchedInsert;
// Objects for the UPSERT syntax (including H2 MERGE, HANA UPSERT, etc.)
private boolean upsertStyle;
private QueryPartList> upsertFields;
private QueryPartList> upsertKeys;
private QueryPartList> upsertValues;
private Select> upsertSelect;
MergeImpl(Configuration configuration, WithImpl with, Table table) {
this(configuration, with, table, null);
}
MergeImpl(Configuration configuration, WithImpl with, Table table, Collection extends Field>> fields) {
super(configuration);
this.with = with;
this.table = table;
this.on = new ConditionProviderImpl();
if (fields != null)
columns(fields);
}
// -------------------------------------------------------------------------
// UPSERT API
// -------------------------------------------------------------------------
QueryPartList> getUpsertFields() {
if (upsertFields == null) {
upsertFields = new QueryPartList>(table.fields());
}
return upsertFields;
}
QueryPartList> getUpsertKeys() {
if (upsertKeys == null) {
upsertKeys = new QueryPartList>();
}
return upsertKeys;
}
QueryPartList> getUpsertValues() {
if (upsertValues == null) {
upsertValues = new QueryPartList>();
}
return upsertValues;
}
@Override
public final MergeImpl columns(Field>... fields) {
return columns(Arrays.asList(fields));
}
@Override
public final MergeImpl columns(Collection extends Field>> fields) {
upsertStyle = true;
upsertFields = new QueryPartList>(fields);
return this;
}
// [jooq-tools] START [columns]
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1) {
return columns(Arrays.asList(field1));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2) {
return columns(Arrays.asList(field1, field2));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3) {
return columns(Arrays.asList(field1, field2, field3));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4) {
return columns(Arrays.asList(field1, field2, field3, field4));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5) {
return columns(Arrays.asList(field1, field2, field3, field4, field5));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field field16, Field field17) {
return columns(Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17));
}
@Generated("This method was generated using jOOQ-tools")
@Override
@SuppressWarnings("hiding")
public MergeImpl columns(Field field1, Field field2, Field field3, Field field4, Field field5, Field field6, Field field7, Field field8, Field field9, Field field10, Field field11, Field field12, Field field13, Field field14, Field field15, Field