Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.jooq.impl.MergeImpl Maven / Gradle / Ivy
/**
* Copyright (c) 2009-2014, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* =============================================================================
* You may choose which license applies to you:
*
* - If you're using this work with Open Source databases, you may choose
* either ASL or jOOQ License.
* - If you're using this work with at least one commercial database, you must
* choose jOOQ License
*
* For more information, please visit http://www.jooq.org/licenses
*
* Apache Software License 2.0:
* -----------------------------------------------------------------------------
* 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.
*
* jOOQ License and Maintenance Agreement:
* -----------------------------------------------------------------------------
* Data Geekery grants the Customer the non-exclusive, timely limited and
* non-transferable license to install and use the Software under the terms of
* the jOOQ License and Maintenance Agreement.
*
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
*/
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.SQLDialect.H2;
// ...
import static org.jooq.impl.DSL.condition;
import static org.jooq.impl.DSL.exists;
import static org.jooq.impl.DSL.notExists;
import static org.jooq.impl.DSL.nullSafe;
import static org.jooq.impl.Utils.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 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.Select;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.UniqueKey;
import org.jooq.exception.SQLDialectNotSupportedException;
import org.jooq.tools.StringUtils;
/**
* The SQL standard MERGE statement
*
* @author Lukas Eder
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
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 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 H2-specific syntax
private boolean h2Style;
private QueryPartList> h2Fields;
private QueryPartList> h2Keys;
private QueryPartList> h2Values;
private Select> h2Select;
MergeImpl(Configuration configuration, Table table) {
this(configuration, table, null);
}
MergeImpl(Configuration configuration, Table table, Collection extends Field>> fields) {
super(configuration);
this.table = table;
this.on = new ConditionProviderImpl();
if (fields != null) {
h2Style = true;
h2Fields = new QueryPartList>(fields);
}
}
// -------------------------------------------------------------------------
// H2-specific MERGE API
// -------------------------------------------------------------------------
QueryPartList> getH2Fields() {
if (h2Fields == null) {
h2Fields = new QueryPartList>(table.fields());
}
return h2Fields;
}
QueryPartList> getH2Keys() {
if (h2Keys == null) {
h2Keys = new QueryPartList>();
}
return h2Keys;
}
QueryPartList> getH2Values() {
if (h2Values == null) {
h2Values = new QueryPartList>();
}
return h2Values;
}
@Override
public final MergeImpl select(Select select) {
h2Style = true;
h2Select = select;
return this;
}
@Override
public final MergeImpl key(Field>... k) {
return key(Arrays.asList(k));
}
@Override
public final MergeImpl key(Collection extends Field>> keys) {
h2Style = true;
getH2Keys().addAll(keys);
return this;
}
// -------------------------------------------------------------------------
// Shared MERGE API
// -------------------------------------------------------------------------
// [jooq-tools] START [values]
@Override
public final MergeImpl values(T1 value1) {
return values(new Object[] { value1 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2) {
return values(new Object[] { value1, value2 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3) {
return values(new Object[] { value1, value2, value3 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4) {
return values(new Object[] { value1, value2, value3, value4 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) {
return values(new Object[] { value1, value2, value3, value4, value5 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
return values(new Object[] { value1, value2, value3, value4, value5, value6 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21 });
}
@Override
public final MergeImpl values(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22) {
return values(new Object[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22 });
}
@Override
public final MergeImpl values(Field value1) {
return values(new Field[] { value1 });
}
@Override
public final MergeImpl values(Field value1, Field value2) {
return values(new Field[] { value1, value2 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3) {
return values(new Field[] { value1, value2, value3 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4) {
return values(new Field[] { value1, value2, value3, value4 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5) {
return values(new Field[] { value1, value2, value3, value4, value5 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6) {
return values(new Field[] { value1, value2, value3, value4, value5, value6 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12, Field value13) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12, Field value13, Field value14) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12, Field value13, Field value14, Field value15) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12, Field value13, Field value14, Field value15, Field value16) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12, Field value13, Field value14, Field value15, Field value16, Field value17) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12, Field value13, Field value14, Field value15, Field value16, Field value17, Field value18) {
return values(new Field[] { value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18 });
}
@Override
public final MergeImpl values(Field value1, Field value2, Field value3, Field value4, Field value5, Field value6, Field value7, Field value8, Field value9, Field value10, Field value11, Field value12, Field value13, Field value14, Field value15, Field