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.
/**
* 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 java.util.Arrays.asList;
import static org.jooq.Clause.UPDATE;
import static org.jooq.Clause.UPDATE_FROM;
import static org.jooq.Clause.UPDATE_RETURNING;
import static org.jooq.Clause.UPDATE_SET;
import static org.jooq.Clause.UPDATE_SET_ASSIGNMENT;
import static org.jooq.Clause.UPDATE_UPDATE;
import static org.jooq.Clause.UPDATE_WHERE;
// ...
// ...
import static org.jooq.impl.DSL.select;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
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.Operator;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record10;
import org.jooq.Record11;
import org.jooq.Record12;
import org.jooq.Record13;
import org.jooq.Record14;
import org.jooq.Record15;
import org.jooq.Record16;
import org.jooq.Record17;
import org.jooq.Record18;
import org.jooq.Record19;
import org.jooq.Record2;
import org.jooq.Record20;
import org.jooq.Record21;
import org.jooq.Record22;
import org.jooq.Record3;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.Record9;
import org.jooq.Row;
import org.jooq.Row1;
import org.jooq.Row10;
import org.jooq.Row11;
import org.jooq.Row12;
import org.jooq.Row13;
import org.jooq.Row14;
import org.jooq.Row15;
import org.jooq.Row16;
import org.jooq.Row17;
import org.jooq.Row18;
import org.jooq.Row19;
import org.jooq.Row2;
import org.jooq.Row20;
import org.jooq.Row21;
import org.jooq.Row22;
import org.jooq.Row3;
import org.jooq.Row4;
import org.jooq.Row5;
import org.jooq.Row6;
import org.jooq.Row7;
import org.jooq.Row8;
import org.jooq.Row9;
import org.jooq.Select;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.UpdateQuery;
/**
* @author Lukas Eder
*/
class UpdateQueryImpl extends AbstractStoreQuery implements UpdateQuery {
private static final long serialVersionUID = -660460731970074719L;
private static final Clause[] CLAUSES = { UPDATE };
private final FieldMapForUpdate updateMap;
private final TableList from;
private final ConditionProviderImpl condition;
private Row multiRow;
private Row multiValue;
private Select> multiSelect;
UpdateQueryImpl(Configuration configuration, Table table) {
super(configuration, table);
this.updateMap = new FieldMapForUpdate(UPDATE_SET_ASSIGNMENT);
this.from = new TableList();
this.condition = new ConditionProviderImpl();
}
@Override
protected final FieldMapForUpdate getValues() {
return updateMap;
}
// [jooq-tools] START [addValues]
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row1 row, Row1 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row2 row, Row2 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row3 row, Row3 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row4 row, Row4 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row5 row, Row5 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row6 row, Row6 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row7 row, Row7 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row8 row, Row8 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row9 row, Row9 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row10 row, Row10 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row11 row, Row11 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row12 row, Row12 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row13 row, Row13 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row14 row, Row14 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row15 row, Row15 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row16 row, Row16 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row17 row, Row17 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row18 row, Row18 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row19 row, Row19 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row20 row, Row20 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row21 row, Row21 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row22 row, Row22 value) {
addValues0(row, value);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row1 row, Select extends Record1> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row2 row, Select extends Record2> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row3 row, Select extends Record3> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row4 row, Select extends Record4> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row5 row, Select extends Record5> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row6 row, Select extends Record6> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row7 row, Select extends Record7> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row8 row, Select extends Record8> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row9 row, Select extends Record9> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row10 row, Select extends Record10> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row11 row, Select extends Record11> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row12 row, Select extends Record12> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row13 row, Select extends Record13> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row14 row, Select extends Record14> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row15 row, Select extends Record15> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row16 row, Select extends Record16> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row17 row, Select extends Record17> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row18 row, Select extends Record18> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row19 row, Select extends Record19> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row20 row, Select extends Record20> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row21 row, Select extends Record21> select) {
addValues0(row, select);
}
@Generated("This method was generated using jOOQ-tools")
@Override
public final void addValues(Row22 row, Select extends Record22> select) {
addValues0(row, select);
}
// [jooq-tools] END [addValues]
private final void addValues0(Row row, Row value) {
multiRow = row;
multiValue = value;
}
private final void addValues0(Row row, Select> select) {
multiRow = row;
multiSelect = select;
}
@Override
public final void addValues(Map extends Field>, ?> map) {
updateMap.set(map);
}
@Override
public final void addFrom(Collection extends TableLike>> f) {
for (TableLike> provider : f) {
from.add(provider.asTable());
}
}
@Override
public final void addFrom(TableLike> f) {
addFrom(Arrays.asList(f));
}
@Override
public final void addFrom(TableLike>... f) {
addFrom(Arrays.asList(f));
}
@Override
public final void addConditions(Collection extends Condition> conditions) {
condition.addConditions(conditions);
}
@Override
public final void addConditions(Condition... conditions) {
condition.addConditions(conditions);
}
@Override
public final void addConditions(Operator operator, Condition... conditions) {
condition.addConditions(operator, conditions);
}
@Override
public final void addConditions(Operator operator, Collection extends Condition> conditions) {
condition.addConditions(operator, conditions);
}
final Condition getWhere() {
return condition.getWhere();
}
@Override
final void accept0(Context> ctx) {
ctx.start(UPDATE_UPDATE)
.keyword("update")
.sql(" ")
.declareTables(true)
.visit(getInto())
.declareTables(false)
.end(UPDATE_UPDATE);
/* [pro] xx
xx xxxxxxx xxxxxx xxx x xxxxxxx xxxxxxxxxxxxx xx xxx xxxxxx xx xxxx xxxxxx
xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxx
xx xxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxx xx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxx
x
xxxxxxxxxxxxxxxxxxxxx
x
xx [/pro] */
ctx.formatSeparator()
.start(UPDATE_SET)
.keyword("set")
.sql(" ");
// A multi-row update was specified
if (multiRow != null) {
boolean qualify = ctx.qualify();
ctx.start(UPDATE_SET_ASSIGNMENT)
.qualify(false)
.visit(multiRow)
.qualify(qualify)
.sql(" = ");
// Some dialects don't really support row value expressions on the
// right hand side of a SET clause
if (multiValue != null && !asList().contains(ctx.configuration().dialect().family())) {
ctx.visit(multiValue);
}
// Subselects or subselect simulations of row value expressions
else {
Select> select = multiSelect;
if (multiValue != null) {
select = select(multiValue.fields());
}
ctx.sql("(")
.formatIndentStart()
.formatNewLine()
.subquery(true)
.visit(select)
.subquery(false)
.formatIndentEnd()
.formatNewLine()
.sql(")");
}
ctx.end(UPDATE_SET_ASSIGNMENT);
}
// A regular (non-multi-row) update was specified
else {
ctx.formatIndentLockStart()
.visit(updateMap)
.formatIndentLockEnd();
}
ctx.end(UPDATE_SET);
switch (ctx.configuration().dialect().family()) {
/* [pro] xx
xx xxxxxxx xxxxxx xxx x xxxxxxx xxxxxxxxxxxxx xx xxx xxxxxx xx xxxx xxxxxx
xxxx xxxxxxx
xxxxxx
xx [/pro] */
default:
ctx.start(UPDATE_FROM);
if (!from.isEmpty()) {
ctx.formatSeparator()
.keyword("from").sql(" ")
.declareTables(true)
.visit(from)
.declareTables(false);
}
ctx.end(UPDATE_FROM);
break;
}
ctx.start(UPDATE_WHERE);
if (!(getWhere() instanceof TrueCondition)) {
ctx.formatSeparator()
.keyword("where").sql(" ")
.visit(getWhere());
}
ctx.end(UPDATE_WHERE)
.start(UPDATE_RETURNING);
toSQLReturning(ctx);
ctx.end(UPDATE_RETURNING);
}
@Override
public final Clause[] clauses(Context> ctx) {
return CLAUSES;
}
@Override
public final boolean isExecutable() {
return updateMap.size() > 0 || multiRow != null;
}
}