Release 3.5.0

This commit is contained in:
Lukas Eder 2014-11-21 16:47:33 +01:00
parent 8e7525f68a
commit c0cb49522e
13 changed files with 0 additions and 1221 deletions

View File

@ -1,101 +0,0 @@
/**
* This class is generated by jOOQ
*/
package org.jooq.util.postgres.pg_catalog.routines;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.0" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class PgCursor extends org.jooq.impl.AbstractRoutine<java.lang.Void> {
private static final long serialVersionUID = 1657262595;
/**
* The parameter <code>pg_catalog.pg_cursor.name</code>.
*/
public static final org.jooq.Parameter<java.lang.String> NAME = createParameter("name", org.jooq.impl.SQLDataType.CLOB);
/**
* The parameter <code>pg_catalog.pg_cursor.statement</code>.
*/
public static final org.jooq.Parameter<java.lang.String> STATEMENT = createParameter("statement", org.jooq.impl.SQLDataType.CLOB);
/**
* The parameter <code>pg_catalog.pg_cursor.is_holdable</code>.
*/
public static final org.jooq.Parameter<java.lang.Boolean> IS_HOLDABLE = createParameter("is_holdable", org.jooq.impl.SQLDataType.BOOLEAN);
/**
* The parameter <code>pg_catalog.pg_cursor.is_binary</code>.
*/
public static final org.jooq.Parameter<java.lang.Boolean> IS_BINARY = createParameter("is_binary", org.jooq.impl.SQLDataType.BOOLEAN);
/**
* The parameter <code>pg_catalog.pg_cursor.is_scrollable</code>.
*/
public static final org.jooq.Parameter<java.lang.Boolean> IS_SCROLLABLE = createParameter("is_scrollable", org.jooq.impl.SQLDataType.BOOLEAN);
/**
* The parameter <code>pg_catalog.pg_cursor.creation_time</code>.
*/
public static final org.jooq.Parameter<java.sql.Timestamp> CREATION_TIME = createParameter("creation_time", org.jooq.impl.SQLDataType.TIMESTAMP);
/**
* Create a new routine call instance
*/
public PgCursor() {
super("pg_cursor", org.jooq.util.postgres.pg_catalog.PgCatalog.PG_CATALOG);
addOutParameter(NAME);
addOutParameter(STATEMENT);
addOutParameter(IS_HOLDABLE);
addOutParameter(IS_BINARY);
addOutParameter(IS_SCROLLABLE);
addOutParameter(CREATION_TIME);
}
/**
* Get the <code>name</code> parameter OUT value from the routine
*/
public java.lang.String getName_() {
return getValue(NAME);
}
/**
* Get the <code>statement</code> parameter OUT value from the routine
*/
public java.lang.String getStatement() {
return getValue(STATEMENT);
}
/**
* Get the <code>is_holdable</code> parameter OUT value from the routine
*/
public java.lang.Boolean getIsHoldable() {
return getValue(IS_HOLDABLE);
}
/**
* Get the <code>is_binary</code> parameter OUT value from the routine
*/
public java.lang.Boolean getIsBinary() {
return getValue(IS_BINARY);
}
/**
* Get the <code>is_scrollable</code> parameter OUT value from the routine
*/
public java.lang.Boolean getIsScrollable() {
return getValue(IS_SCROLLABLE);
}
/**
* Get the <code>creation_time</code> parameter OUT value from the routine
*/
public java.sql.Timestamp getCreationTime() {
return getValue(CREATION_TIME);
}
}

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:annox="http://annox.dev.java.net"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
version="2.1">
<jaxb:globalBindings>
<!-- Force all classes implements Serializable -->
<xjc:serializable uid="340" />
<!-- [#2401] Trim unnecessary whitespace from configuration -->
<xjc:javaType name="java.lang.String" xmlType="xs:string" adapter="org.jooq.util.jaxb.tools.TrimAdapter"/>
</jaxb:globalBindings>
<!-- Annotate the following classes with @SuppressWarnings -->
<jaxb:bindings schemaLocation="../xsd/jooq-codegen-3.4.0.xsd" multiple="true" node="//xs:complexType">
<annox:annotate>
<annox:annotate annox:class="java.lang.SuppressWarnings" value="all" />
</annox:annotate>
</jaxb:bindings>
</jaxb:bindings>

View File

@ -1,49 +0,0 @@
/**
* 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;
public interface BindingContext {
Configuration configuration();
SQLDialect dialect();
SQLDialect family();
}

View File

@ -1,72 +0,0 @@
/**
* 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 org.jooq.BindingContext;
import org.jooq.Configuration;
import org.jooq.SQLDialect;
/**
* @author Lukas Eder
*/
abstract class AbstractBindingContext implements BindingContext {
private final Configuration configuration;
AbstractBindingContext(Configuration configuration) {
this.configuration = configuration;
}
@Override
public final Configuration configuration() {
return configuration;
}
@Override
public final SQLDialect dialect() {
return configuration.dialect();
}
@Override
public final SQLDialect family() {
return configuration.dialect().family();
}
}

View File

@ -1,168 +0,0 @@
/**
* 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.impl.Utils.fieldArray;
import java.sql.ResultSetMetaData;
import java.util.List;
import org.jooq.Configuration;
import org.jooq.DataType;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.Row;
import org.jooq.Select;
import org.jooq.Table;
import org.jooq.exception.DataAccessException;
/**
* A common base class for all <code>SELECT</code> statements.
*
* @author Lukas Eder
*/
abstract class AbstractSelect<R extends Record> extends AbstractResultQuery<R> implements Select<R> {
private static final long serialVersionUID = 5432006637149005588L;
AbstractSelect(Configuration configuration) {
super(configuration);
}
@Override
public final int fetchCount() throws DataAccessException {
return DSL.using(configuration()).fetchCount(this);
}
@Override
public final Select<R> union(Select<? extends R> select) {
return new Union<R>(configuration(), this, select, CombineOperator.UNION);
}
@Override
public final Select<R> unionAll(Select<? extends R> select) {
return new Union<R>(configuration(), this, select, CombineOperator.UNION_ALL);
}
@Override
public final Select<R> except(Select<? extends R> select) {
return new Union<R>(configuration(), this, select, CombineOperator.EXCEPT);
}
@Override
public final Select<R> intersect(Select<? extends R> select) {
return new Union<R>(configuration(), this, select, CombineOperator.INTERSECT);
}
@SuppressWarnings("unchecked")
@Override
public final <T> Field<T> asField() {
if (getSelect().size() != 1) {
throw new IllegalStateException("Can only use single-column ResultProviderQuery as a field");
}
return new ScalarSubquery<T>(this, (DataType<T>) getSelect().get(0).getDataType());
}
@Override
public final <T> Field<T> asField(String alias) {
return this.<T> asField().as(alias);
}
@Override
public final Row fieldsRow() {
return asTable().fieldsRow();
}
@Override
public final <T> Field<T> field(Field<T> field) {
return asTable().field(field);
}
@Override
public final Field<?> field(String string) {
return asTable().field(string);
}
@Override
public final Field<?> field(int index) {
return asTable().field(index);
}
@Override
public final Field<?>[] fields() {
return asTable().fields();
}
@Override
public final Table<R> asTable() {
// Its usually better to alias nested selects that are used in
// the FROM clause of a query
return new DerivedTable<R>(this).as("alias_" + Utils.hash(this));
}
@Override
public final Table<R> asTable(String alias) {
return new DerivedTable<R>(this).as(alias);
}
@Override
public final Table<R> asTable(String alias, String... fieldAliases) {
return new DerivedTable<R>(this).as(alias, fieldAliases);
}
@Override
protected final Field<?>[] getFields(ResultSetMetaData meta) {
// [#1808] TODO: Restrict this field list, in case a restricting fetch()
// method was called to get here
List<Field<?>> fields = getSelect();
// If no projection was specified explicitly, create fields from result
// set meta data instead. This is typically the case for SELECT * ...
if (fields.isEmpty()) {
Configuration configuration = configuration();
return new MetaDataFieldProvider(configuration, meta).getFields();
}
return fieldArray(fields);
}
}

View File

@ -1,115 +0,0 @@
/**
* 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 java.sql.Array;
import java.sql.ResultSet;
import java.util.Map;
import org.jooq.SQLDialect;
import org.jooq.exception.SQLDialectNotSupportedException;
class DefaultArray implements Array {
private final SQLDialect dialect;
private final Object[] array;
private final Class<?> type;
public DefaultArray(SQLDialect dialect, Object[] array, Class<?> type) {
this.dialect = dialect;
this.array = array;
this.type = type;
}
@Override
public String getBaseTypeName() {
return DefaultDataType.getDataType(dialect, type.getComponentType()).getTypeName();
}
@Override
public int getBaseType() {
throw new SQLDialectNotSupportedException("Array.getBaseType()");
}
@Override
public Object getArray() {
return array;
}
@Override
public Object getArray(Map<String, Class<?>> map) {
return array;
}
@Override
public Object getArray(long index, int count) {
throw new SQLDialectNotSupportedException("Array.getArray(long, int)");
}
@Override
public Object getArray(long index, int count, Map<String, Class<?>> map) {
throw new SQLDialectNotSupportedException("Array.getArray(long, int, Map)");
}
@Override
public ResultSet getResultSet() {
throw new SQLDialectNotSupportedException("Array.getResultSet()");
}
@Override
public ResultSet getResultSet(Map<String, Class<?>> map) {
throw new SQLDialectNotSupportedException("Array.getResultSet(Map)");
}
@Override
public ResultSet getResultSet(long index, int count) {
throw new SQLDialectNotSupportedException("Array.getResultSet(long, int)");
}
@Override
public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) {
throw new SQLDialectNotSupportedException("Array.getResultSet(long, int, Map)");
}
@Override
public void free() {
}
}

View File

@ -1,53 +0,0 @@
/**
* 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 org.jooq.Configuration;
/**
* @author Lukas Eder
*/
@Deprecated
class DefaultBindingContext extends AbstractBindingContext {
DefaultBindingContext(Configuration configuration) {
super(configuration);
}
}

View File

@ -1,63 +0,0 @@
/**
* 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;
/**
* An operator for the {@link ExistsCondition}
*
* @author Lukas Eder
*/
enum ExistsOperator {
EXISTS("exists"),
NOT_EXISTS("not exists");
private final String sql;
private ExistsOperator(String sql) {
this.sql = sql;
}
public String toSQL() {
return sql;
}
}

View File

@ -1,102 +0,0 @@
/**
* 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.CONDITION;
import static org.jooq.Clause.CONDITION_EXISTS;
import static org.jooq.Clause.CONDITION_NOT_EXISTS;
import static org.jooq.impl.ExistsOperator.EXISTS;
import org.jooq.Clause;
import org.jooq.Context;
import org.jooq.Select;
/**
* @author Lukas Eder
*/
class SelectQueryAsExistsCondition extends AbstractCondition {
private static final long serialVersionUID = 5678338161136603292L;
private static final Clause[] CLAUSES_EXISTS = { CONDITION, CONDITION_EXISTS };
private static final Clause[] CLAUSES_EXISTS_NOT = { CONDITION, CONDITION_NOT_EXISTS };
private final Select<?> query;
private final ExistsOperator operator;
SelectQueryAsExistsCondition(Select<?> query, ExistsOperator operator) {
this.query = query;
this.operator = operator;
}
@Override
public final void accept(Context<?> ctx) {
// If this is already a subquery, proceed
if (ctx.subquery()) {
ctx.keyword(operator.toSQL())
.sql(" (")
.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine()
.sql(")");
}
else {
ctx.keyword(operator.toSQL())
.sql(" (")
.subquery(true)
.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine()
.subquery(false)
.sql(")");
}
}
@Override
public final Clause[] clauses(Context<?> ctx) {
return operator == EXISTS ? CLAUSES_EXISTS : CLAUSES_EXISTS_NOT;
}
}

View File

@ -1,94 +0,0 @@
/**
* 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 org.jooq.Context;
import org.jooq.DataType;
import org.jooq.Field;
import org.jooq.Select;
/**
* @author Lukas Eder
*/
class SelectQueryAsField<T> extends AbstractField<T> {
private static final long serialVersionUID = 3463144434073231750L;
private final Select<?> query;
SelectQueryAsField(Select<?> query, DataType<T> type) {
super("select", type);
this.query = query;
}
@Override
public final Field<T> as(String alias) {
return new FieldAlias<T>(this, alias);
}
@Override
public final void accept(Context<?> ctx) {
// If this is already a subquery, proceed
if (ctx.subquery()) {
ctx.sql("(")
.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine()
.sql(")");
}
else {
ctx.sql("(")
.subquery(true)
.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine()
.subquery(false)
.sql(")");
}
}
}

View File

@ -1,107 +0,0 @@
/**
* 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.CONDITION;
import static org.jooq.Clause.CONDITION_COMPARISON;
import org.jooq.Clause;
import org.jooq.Comparator;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.Select;
/**
* @author Lukas Eder
*/
class SelectQueryAsSubQueryCondition extends AbstractCondition {
private static final long serialVersionUID = -402776705884329740L;
private static final Clause[] CLAUSES = { CONDITION, CONDITION_COMPARISON };
private final Select<?> query;
private final Field<?> field;
private final Comparator comparator;
SelectQueryAsSubQueryCondition(Select<?> query, Field<?> field, Comparator comparator) {
this.query = query;
this.field = field;
this.comparator = comparator;
}
@Override
public final void accept(Context<?> ctx) {
// If this is already a subquery, proceed
if (ctx.subquery()) {
ctx.visit(field)
.sql(" ")
.keyword(comparator.toSQL())
.sql(" (")
.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine()
.sql(")");
}
else {
ctx.visit(field)
.sql(" ")
.keyword(comparator.toSQL())
.sql(" (")
.subquery(true)
.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine()
.subquery(false)
.sql(")");
}
}
@Override
public final Clause[] clauses(Context<?> ctx) {
return CLAUSES;
}
}

View File

@ -1,115 +0,0 @@
/**
* 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 org.jooq.Clause;
import org.jooq.Context;
import org.jooq.Record;
import org.jooq.Select;
import org.jooq.Table;
/**
* @author Lukas Eder
*/
class SelectQueryAsTable<R extends Record> extends AbstractTable<R> {
private static final long serialVersionUID = 6272398035926615668L;
private final Select<R> query;
SelectQueryAsTable(Select<R> query) {
super("select");
this.query = query;
}
final Select<R> query() {
return query;
}
@Override
public final Table<R> as(String alias) {
return new TableAlias<R>(this, alias, true);
}
@Override
public final Table<R> as(String alias, String... fieldAliases) {
return new TableAlias<R>(this, alias, fieldAliases, true);
}
@Override
final Fields<R> fields0() {
return new Fields<R>(query.getSelect());
}
@Override
public final Class<? extends R> getRecordType() {
return query.getRecordType();
}
@Override
public final void accept(Context<?> ctx) {
// If this is already a subquery, proceed
if (ctx.subquery()) {
ctx.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine();
}
else {
ctx.subquery(true)
.formatIndentStart()
.formatNewLine()
.visit(query)
.formatIndentEnd()
.formatNewLine()
.subquery(false);
}
}
@Override
public final Clause[] clauses(Context<?> ctx) {
return null;
}
}

View File

@ -1,155 +0,0 @@
/**
* 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.SELECT_EXCEPT;
import static org.jooq.Clause.SELECT_INTERSECT;
import static org.jooq.Clause.SELECT_UNION;
import static org.jooq.Clause.SELECT_UNION_ALL;
import java.util.ArrayList;
import java.util.List;
import org.jooq.Clause;
import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.Select;
/**
* A union is a <code>SELECT</code> statement that combines several sub-selects
* with a <code>UNION</code> or a similar operator.
*
* @author Lukas Eder
*/
class Union<R extends Record> extends AbstractSelect<R> {
private static final long serialVersionUID = 7491446471677986172L;
private final List<Select<? extends R>> queries;
private final CombineOperator operator;
private final Clause[] clauses;
Union(Configuration configuration, Select<R> query1, Select<? extends R> query2, CombineOperator operator) {
super(configuration);
this.queries = new ArrayList<Select<? extends R>>();
this.queries.add(query1);
this.queries.add(query2);
this.operator = operator;
switch (operator) {
case EXCEPT: this.clauses = new Clause[] { SELECT_EXCEPT } ; break;
case INTERSECT: this.clauses = new Clause[] { SELECT_INTERSECT } ; break;
case UNION: this.clauses = new Clause[] { SELECT_UNION } ; break;
case UNION_ALL: this.clauses = new Clause[] { SELECT_UNION_ALL } ; break;
default: throw new IllegalArgumentException("Operator not supported : " + operator);
}
}
@Override
public final Class<? extends R> getRecordType() {
return queries.get(0).getRecordType();
}
@Override
public final List<Field<?>> getSelect() {
return queries.get(0).getSelect();
}
@Override
public final void accept(Context<?> ctx) {
for (int i = 0; i < queries.size(); i++) {
if (i != 0) {
ctx.formatSeparator()
.keyword(operator.toSQL(ctx.configuration().dialect()))
.formatSeparator();
}
wrappingParenthesis(ctx, "(");
ctx.visit(queries.get(i));
wrappingParenthesis(ctx, ")");
}
}
private final void wrappingParenthesis(Context<?> ctx, String parenthesis) {
switch (ctx.configuration().dialect()) {
// Sybase ASE, Derby, Firebird and SQLite have some syntax issues with unions.
// Check out https://issues.apache.org/jira/browse/DERBY-2374
/* [pro] xx
xxxx xxxxxxx
xxxx xxxx
xx [/pro] */
case DERBY:
case FIREBIRD:
case SQLITE:
// [#288] MySQL has a very special way of dealing with UNION's
// So include it as well
case MARIADB:
case MYSQL:
return;
}
if (")".equals(parenthesis)) {
ctx.formatIndentEnd()
.formatNewLine();
}
ctx.sql(parenthesis);
if ("(".equals(parenthesis)) {
ctx.formatIndentStart()
.formatNewLine();
}
}
@Override
public final Clause[] clauses(Context<?> ctx) {
return clauses;
}
@Override
final boolean isForUpdate() {
return false;
}
}