[#3248] Add support for Binding (i.e. "Type Providers")

This commit is contained in:
Lukas Eder 2014-10-30 14:51:15 +01:00
parent 0e1c9869d9
commit cf675a8877
50 changed files with 4453 additions and 2514 deletions

View File

@ -3,3 +3,4 @@
.settings
/target
/*.iml
/bin/

View File

@ -0,0 +1,184 @@
/**
* 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;
import java.io.Serializable;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;
import java.sql.Timestamp;
import org.jooq.exception.DataAccessException;
import org.jooq.impl.DefaultBinding;
/**
* An SPI (Service Provider Interface) that exposes all low-level interactions
* with JDBC bind variables.
* <p>
* This SPI is used by jOOQ users to implement support for custom data types
* that would otherwise not be supported by jOOQ and/or JDBC. All of jOOQ's
* internal support for bind variable types is implemented in
* {@link DefaultBinding}.
*
* @author Lukas Eder
*/
public interface Binding<T> extends Serializable {
/**
* Generate SQL code for the bind variable.
* <p>
* Implementations should generate SQL code onto
* {@link BindingSQLContext#render()}, given the context's bind variable
* located at {@link BindingSQLContext#value()}. Examples of such SQL code
* are:
* <ul>
* <li><code>"?"</code>: Default implementations can simply generate a
* question mark.<br>
* <br>
* </li>
* <li><code>"123"</code>: Implementations may choose to inline bind
* variables to influence execution plan generation.<br>
* <br>
* {@link RenderContext#paramType()} contains information whether inlined
* bind variables are expected in the current context.<br>
* <br>
* </li>
* <li><code>"CAST(? AS DATE)"</code>: Cast a database to a more specific
* type. This can be useful in databases like Oracle, which map both
* <code>DATE</code> and <code>TIMESTAMP</code> SQL types to
* {@link Timestamp}.<br>
* <br>
* {@link RenderContext#castMode()} may contain some hints about whether
* casting is suggested in the current context.<br>
* <br>
* </li>
* <li><code>"?::json"</code>: Vendor-specific bind variables can be
* supported, e.g. {@link SQLDialect#POSTGRES}'s JSON data type.</li>
* </ul>
* <p>
* Implementations must provide consistent behaviour between
* {@link #sql(BindingSQLContext)} and
* {@link #set(BindingSetStatementContext)}, i.e. when bind variables are
* inlined, then they must not be bound to the {@link PreparedStatement} in
* {@link #set(BindingSetStatementContext)}
*
* @param ctx The context object containing all argument objects.
* @throws SQLException Implementations are allowed to pass on all
* {@link SQLException}s to the caller to be wrapped in
* {@link DataAccessException}s.
*/
void sql(BindingSQLContext<T> ctx) throws SQLException;
/**
* Register a {@link CallableStatement}'s <code>OUT</code> parameter.
*
* @param ctx The context object containing all argument objects.
* @throws SQLException Implementations are allowed to pass on all
* {@link SQLException}s to the caller to be wrapped in
* {@link DataAccessException}s.
*/
void register(BindingRegisterContext<T> ctx) throws SQLException;
/**
* Set a {@link PreparedStatement}'s <code>IN</code> parameter.
*
* @param ctx The context object containing all argument objects.
* @throws SQLException Implementations are allowed to pass on all
* {@link SQLException}s to the caller to be wrapped in
* {@link DataAccessException}s.
*/
void set(BindingSetStatementContext<T> ctx) throws SQLException;
/**
* Set a {@link SQLOutput}'s <code>IN</code> parameter.
*
* @param ctx The context object containing all argument objects.
* @throws SQLException Implementations are allowed to pass on all
* {@link SQLException}s to the caller to be wrapped in
* {@link DataAccessException}s.
*/
void set(BindingSetSQLOutputContext<T> ctx) throws SQLException;
/**
* Get a {@link ResultSet}'s <code>OUT</code> value.
* <p>
* Implementations are expected to produce a value by calling
* {@link BindingGetResultSetContext#value(Object)}, passing the resulting
* value to the method.
*
* @param ctx The context object containing all argument objects.
* @throws SQLException Implementations are allowed to pass on all
* {@link SQLException}s to the caller to be wrapped in
* {@link DataAccessException}s.
*/
void get(BindingGetResultSetContext<T> ctx) throws SQLException;
/**
* Get a {@link CallableStatement}'s <code>OUT</code> value.
* <p>
* Implementations are expected to produce a value by calling
* {@link BindingGetStatementContext#value(Object)}, passing the resulting
* value to the method.
*
* @param ctx The context object containing all argument objects.
* @throws SQLException Implementations are allowed to pass on all
* {@link SQLException}s to the caller to be wrapped in
* {@link DataAccessException}s.
*/
void get(BindingGetStatementContext<T> ctx) throws SQLException;
/**
* Get a {@link SQLInput}'s <code>OUT</code> value.
* <p>
* Implementations are expected to produce a value by calling
* {@link BindingGetSQLInputContext#value(Object)}, passing the resulting
* value to the method.
*
* @param ctx The context object containing all argument objects.
* @throws SQLException Implementations are allowed to pass on all
* {@link SQLException}s to the caller to be wrapped in
* {@link DataAccessException}s.
*/
void get(BindingGetSQLInputContext<T> ctx) throws SQLException;
}

View File

@ -0,0 +1,49 @@
/**
* 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

@ -0,0 +1,67 @@
/**
* 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;
import java.sql.ResultSet;
/**
* A container type for {@link Binding#get(BindingGetResultSetContext)}
* arguments.
*
* @author Lukas Eder
*/
public interface BindingGetResultSetContext<T> extends Scope {
/**
* The {@link ResultSet} from which a value is retrieved.
*/
ResultSet resultSet();
/**
* The column index at which the value is retrieved.
*/
int index();
/**
* A callback to which the resulting value is registered.
*/
void value(T value);
}

View File

@ -0,0 +1,62 @@
/**
* 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;
import java.sql.SQLInput;
/**
* A container type for {@link Binding#get(BindingGetSQLInputContext)}
* arguments.
*
* @author Lukas Eder
*/
public interface BindingGetSQLInputContext<T> extends Scope {
/**
* The {@link SQLInput} from which a value is retrieved.
*/
SQLInput input();
/**
* A callback to which the resulting value is registered.
*/
void value(T value);
}

View File

@ -0,0 +1,67 @@
/**
* 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;
import java.sql.CallableStatement;
/**
* A container type for {@link Binding#get(BindingGetStatementContext)}
* arguments.
*
* @author Lukas Eder
*/
public interface BindingGetStatementContext<T> extends Scope {
/**
* The {@link CallableStatement} from which a value is retrieved.
*/
CallableStatement statement();
/**
* The column index at which the value is retrieved.
*/
int index();
/**
* A callback to which the resulting value is registered.
*/
void value(T value);
}

View File

@ -0,0 +1,63 @@
/**
* 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;
import java.sql.CallableStatement;
/**
* A container type for {@link Binding#register(BindingRegisterContext)}
* arguments.
*
* @author Lukas Eder
*/
public interface BindingRegisterContext<T> extends Scope {
/**
* The {@link CallableStatement} on which a bind variable should be
* registered.
*/
CallableStatement statement();
/**
* The bind variable index at which a bind variable should be registered.
*/
int index();
}

View File

@ -0,0 +1,60 @@
/**
* 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;
/**
* A container type for {@link Binding#sql(BindingSQLContext)} arguments.
*
* @author Lukas Eder
*/
public interface BindingSQLContext<T> extends Scope {
/**
* The {@link RenderContext} that contains the generated SQL and the current
* SQL generation state.
*/
RenderContext render();
/**
* The bind value that is being rendered.
*/
T value();
}

View File

@ -0,0 +1,62 @@
/**
* 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;
import java.sql.SQLOutput;
/**
* A container type for {@link Binding#set(BindingSetSQLOutputContext)}
* arguments.
*
* @author Lukas Eder
*/
public interface BindingSetSQLOutputContext<T> extends Scope {
/**
* The {@link SQLOutput} to which a bind variable should be bound.
*/
SQLOutput output();
/**
* The bind value that is being bound.
*/
T value();
}

View File

@ -0,0 +1,67 @@
/**
* 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;
import java.sql.PreparedStatement;
/**
* A container type for {@link Binding#set(BindingSetStatementContext)}
* arguments.
*
* @author Lukas Eder
*/
public interface BindingSetStatementContext<T> extends Scope {
/**
* The {@link PreparedStatement} to which a bind variable should be bound.
*/
PreparedStatement statement();
/**
* The bind variable index at which a bind variable should be bound.
*/
int index();
/**
* The bind value that is being bound.
*/
T value();
}

View File

@ -41,7 +41,6 @@
package org.jooq;
import java.sql.PreparedStatement;
import java.util.Map;
import org.jooq.RenderContext.CastMode;
import org.jooq.conf.ParamType;
@ -56,93 +55,12 @@ import org.jooq.exception.DataAccessException;
* @see BindContext
* @see RenderContext
*/
public interface Context<C extends Context<C>> {
public interface Context<C extends Context<C>> extends Scope {
// ------------------------------------------------------------------------
// General methods
// ------------------------------------------------------------------------
/**
* The configuration wrapped by this context.
*/
Configuration configuration();
/**
* The settings wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().settings()</code>.
*/
Settings settings();
/**
* The {@link SQLDialect} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect()</code>.
*/
SQLDialect dialect();
/**
* The {@link SQLDialect#family()} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect().family()</code>.
*/
SQLDialect family();
/**
* Get all custom data from this <code>Context</code>.
* <p>
* This is custom data that was previously set to the context using
* {@link #data(Object, Object)}. Use custom data if you want to pass data
* to {@link QueryPart} objects for a given {@link RenderContext} or
* {@link BindContext}.
* <p>
* Unlike {@link Configuration#data()}, these data's lifecycle only
* matches that of a render or bind context.
*
* @return The custom data. This is never <code>null</code>
*/
Map<Object, Object> data();
/**
* Get some custom data from this <code>Context</code>.
* <p>
* This is custom data that was previously set to the context using
* {@link #data(Object, Object)}. Use custom data if you want to pass data
* to {@link QueryPart} objects for a given {@link RenderContext} or
* {@link BindContext}.
* <p>
* Unlike {@link Configuration#data()}, these data's lifecycle only
* matches that of a render or bind context.
*
* @param key A key to identify the custom data
* @return The custom data or <code>null</code> if no such data is contained
* in this <code>ExecuteContext</code>
* @see ExecuteListener
*/
Object data(Object key);
/**
* Set some custom data to this <code>Context</code>.
* <p>
* This is custom data that was previously set to the context using
* {@link #data(Object, Object)}. Use custom data if you want to pass data
* to {@link QueryPart} objects for a given {@link RenderContext} or
* {@link BindContext}.
* <p>
* Unlike {@link Configuration#data()}, these data's lifecycle only
* matches that of a render or bind context.
*
* @param key A key to identify the custom data
* @param value The custom data
* @return The previously set custom data or <code>null</code> if no data
* was previously set for the given key
* @see ExecuteListener
*/
Object data(Object key, Object value);
/**
* Visit a <code>QueryPart</code> in the current <code>Context</code>.
* <p>

View File

@ -113,42 +113,12 @@ import org.jooq.impl.DSL;
* @see Configuration
* @author Lukas Eder
*/
public interface DSLContext {
public interface DSLContext extends Scope {
// -------------------------------------------------------------------------
// XXX Configuration API
// -------------------------------------------------------------------------
/**
* The <code>Configuration</code> referenced from this
* <code>DSLContext</code>.
*/
Configuration configuration();
/**
* The settings wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().settings()</code>.
*/
Settings settings();
/**
* The {@link SQLDialect} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect()</code>.
*/
SQLDialect dialect();
/**
* The {@link SQLDialect#family()} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect().family()</code>.
*/
SQLDialect family();
/**
* Map a schema to another one.
* <p>

View File

@ -58,7 +58,7 @@ import org.jooq.exception.DataAccessException;
* @author Lukas Eder
* @see ExecuteListener
*/
public interface ExecuteContext {
public interface ExecuteContext extends Scope {
/**
* Get all custom data from this <code>ExecuteContext</code>.
@ -110,35 +110,6 @@ public interface ExecuteContext {
*/
Object data(Object key, Object value);
/**
* The configuration wrapped by this context.
*/
Configuration configuration();
/**
* The settings wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().settings()</code>.
*/
Settings settings();
/**
* The {@link SQLDialect} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect()</code>.
*/
SQLDialect dialect();
/**
* The {@link SQLDialect#family()} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect().family()</code>.
*/
SQLDialect family();
/**
* The connection to be used in this execute context.
* <p>

View File

@ -116,6 +116,11 @@ public interface Field<T> extends GroupField {
*/
Converter<?, T> getConverter();
/**
* The field's underlying {@link Binding}.
*/
Binding<T> getBinding();
/**
* The Java type of the field.
*/

View File

@ -69,6 +69,11 @@ public interface Parameter<T> extends QueryPart {
*/
Converter<?, T> getConverter();
/**
* The parameter's underlying {@link Binding}.
*/
Binding<T> getBinding();
/**
* The type of this parameter (might not be dialect-specific)
*/

View File

@ -42,15 +42,13 @@ package org.jooq;
import java.util.Map;
import org.jooq.conf.Settings;
/**
* A context object for {@link Record} manipulation passed to registered
* {@link RecordListener}'s.
*
* @author Lukas Eder
*/
public interface RecordContext {
public interface RecordContext extends Scope {
/**
* Get all custom data from this <code>RecordContext</code>.
@ -102,35 +100,6 @@ public interface RecordContext {
*/
Object data(Object key, Object value);
/**
* The configuration wrapped by this context.
*/
Configuration configuration();
/**
* The settings wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().settings()</code>.
*/
Settings settings();
/**
* The {@link SQLDialect} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect()</code>.
*/
SQLDialect dialect();
/**
* The {@link SQLDialect#family()} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect().family()</code>.
*/
SQLDialect family();
/**
* The type of database interaction that is being executed.
* <p>

View File

@ -0,0 +1,125 @@
/**
* 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;
import java.util.Map;
import org.jooq.conf.Settings;
/**
* Scope implementations provide access to a variety of objects that are
* available from a given scope.
* <p>
* The scope of the various objects contained in this type (e.g.
* {@link #configuration()}, {@link #settings()}, etc.) are implementation
* dependent and will be specified by the concrete subtype of <code>Scope</code>.
*
* @author Lukas Eder
*/
public interface Scope {
/**
* The configuration of the current scope.
*/
Configuration configuration();
/**
* The settings wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().settings()</code>.
*/
Settings settings();
/**
* The {@link SQLDialect} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect()</code>.
*/
SQLDialect dialect();
/**
* The {@link SQLDialect#family()} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect().family()</code>.
*/
SQLDialect family();
/**
* Get all custom data from this <code>Scope</code>.
* <p>
* This is custom data that was previously set to the context using
* {@link #data(Object, Object)}. Use custom data if you want to pass data
* to {@link QueryPart} objects for a given {@link Scope}.
*
* @return The custom data. This is never <code>null</code>
*/
Map<Object, Object> data();
/**
* Get some custom data from this <code>Scope</code>.
* <p>
* This is custom data that was previously set to the context using
* {@link #data(Object, Object)}. Use custom data if you want to pass data
* to {@link QueryPart} objects for a given {@link Scope}
*
* @param key A key to identify the custom data
* @return The custom data or <code>null</code> if no such data is contained
* in this <code>Scope</code>
*/
Object data(Object key);
/**
* Set some custom data to this <code>Scope</code>.
* <p>
* This is custom data that was previously set to the context using
* {@link #data(Object, Object)}. Use custom data if you want to pass data
* to {@link QueryPart} objects for a given {@link Scope}.
*
* @param key A key to identify the custom data
* @param value The custom data
* @return The previously set custom data or <code>null</code> if no data
* was previously set for the given key
*/
Object data(Object key, Object value);
}

View File

@ -40,7 +40,6 @@
*/
package org.jooq;
import org.jooq.conf.Settings;
/**
* A context object that is used to pass arguments to the various methods of
@ -48,36 +47,7 @@ import org.jooq.conf.Settings;
*
* @author Lukas Eder
*/
public interface TransactionContext {
/**
* The configuration scoped to this transaction and its nested transactions.
*/
Configuration configuration();
/**
* The settings wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().settings()</code>.
*/
Settings settings();
/**
* The {@link SQLDialect} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect()</code>.
*/
SQLDialect dialect();
/**
* The {@link SQLDialect#family()} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect().family()</code>.
*/
SQLDialect family();
public interface TransactionContext extends Scope {
/**
* A user-defined transaction object, possibly obtained from

View File

@ -42,8 +42,6 @@ package org.jooq;
import java.util.Map;
import org.jooq.conf.Settings;
/**
* A context object for {@link QueryPart} traversal passed to registered
* {@link VisitListener}'s.
@ -51,7 +49,7 @@ import org.jooq.conf.Settings;
* @author Lukas Eder
* @see VisitListener
*/
public interface VisitContext {
public interface VisitContext extends Scope {
/**
* Get all custom data from this <code>VisitContext</code>.
@ -91,35 +89,6 @@ public interface VisitContext {
*/
Object data(Object key, Object value);
/**
* The configuration wrapped by this context.
*/
Configuration configuration();
/**
* The settings wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().settings()</code>.
*/
Settings settings();
/**
* The {@link SQLDialect} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect()</code>.
*/
SQLDialect dialect();
/**
* The {@link SQLDialect#family()} wrapped by this context.
* <p>
* This method is a convenient way of accessing
* <code>configuration().dialect().family()</code>.
*/
SQLDialect family();
/**
* The most recent clause that was encountered through
* {@link Context#start(Clause)}.

View File

@ -0,0 +1,72 @@
/**
* 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

@ -46,7 +46,6 @@ import static org.jooq.impl.Utils.DATA_OMIT_CLAUSE_EVENT_EMISSION;
import java.sql.PreparedStatement;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import org.jooq.BindContext;
@ -69,11 +68,9 @@ import org.jooq.conf.Settings;
* @author Lukas Eder
*/
@SuppressWarnings("unchecked")
abstract class AbstractContext<C extends Context<C>> implements Context<C> {
abstract class AbstractContext<C extends Context<C>> extends AbstractScope implements Context<C> {
final Configuration configuration;
final PreparedStatement stmt;
final Map<Object, Object> data;
boolean declareFields;
boolean declareTables;
@ -94,9 +91,9 @@ abstract class AbstractContext<C extends Context<C>> implements Context<C> {
CastMode castMode = CastMode.DEFAULT;
AbstractContext(Configuration configuration, PreparedStatement stmt) {
this.configuration = configuration;
super(configuration);
this.stmt = stmt;
this.data = new HashMap<Object, Object>();
this.visitClauses = new ArrayDeque<Clause>();
VisitListenerProvider[] providers = configuration.visitListenerProviders();
@ -316,41 +313,6 @@ abstract class AbstractContext<C extends Context<C>> implements Context<C> {
// XXX Context API
// ------------------------------------------------------------------------
@Override
public final Configuration configuration() {
return configuration;
}
@Override
public final Settings settings() {
return Utils.settings(configuration());
}
@Override
public final SQLDialect dialect() {
return Utils.configuration(configuration()).dialect();
}
@Override
public final SQLDialect family() {
return dialect().family();
}
@Override
public final Map<Object, Object> data() {
return data;
}
@Override
public final Object data(Object key) {
return data.get(key);
}
@Override
public final Object data(Object key, Object value) {
return data.put(key, value);
}
private final C visit0(QueryPart part) {
if (part != null) {
QueryPartInternal internal = (QueryPartInternal) part;

View File

@ -77,6 +77,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.jooq.BetweenAndStep;
import org.jooq.Binding;
import org.jooq.CaseValueStep;
import org.jooq.CaseWhenStep;
import org.jooq.Clause;
@ -113,6 +114,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
private final String comment;
private final DataType<T> dataType;
private final Converter<?, T> converter;
private final Binding<T> binding;
AbstractField(String name, DataType<T> type) {
this(name, type, null, null);
@ -131,6 +133,8 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
: type instanceof ConvertedDataType
? ((ConvertedDataType<?, T>) type).converter()
: new IdentityConverter<T>(type.getType());
this.binding = new DefaultBinding(this.converter, type.isLob());
}
// ------------------------------------------------------------------------
@ -174,6 +178,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
return converter;
}
@Override
public final Binding<T> getBinding() {
return binding;
}
@Override
public final DataType<T> getDataType() {
return dataType;

View File

@ -57,7 +57,6 @@ import static org.jooq.impl.Utils.settings;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -67,7 +66,6 @@ import java.util.Map;
import java.util.Set;
import org.jooq.AggregateFunction;
// ...
import org.jooq.AttachableInternal;
import org.jooq.BindContext;
import org.jooq.Clause;
@ -86,7 +84,6 @@ import org.jooq.Result;
import org.jooq.Routine;
import org.jooq.Schema;
import org.jooq.UDTField;
import org.jooq.UDTRecord;
import org.jooq.exception.ControlFlowSignal;
import org.jooq.tools.Convert;
@ -559,13 +556,22 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
if (parameter.equals(getReturnParameter()) ||
getOutParameters().contains(parameter)) {
int index = parameterIndexes.get(parameter);
results.put(parameter, Utils.getFromStatement(ctx, parameter, index));
fetchOutParameter(ctx, parameter);
}
}
}
@SuppressWarnings("unchecked")
private final <U> void fetchOutParameter(ExecuteContext ctx, Parameter<U> parameter) throws SQLException {
DefaultBindingGetStatementContext<U> out = new DefaultBindingGetStatementContext<U>(
ctx.configuration(),
(CallableStatement) ctx.statement(),
parameterIndexes.get(parameter)
);
parameter.getBinding().get(out);
results.put(parameter, out.value());
}
private final void registerOutParameters(Configuration c, CallableStatement statement) throws SQLException {
// Register all out / inout parameters according to their position
@ -574,47 +580,15 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
if (parameter.equals(getReturnParameter()) ||
getOutParameters().contains(parameter)) {
int index = parameterIndexes.get(parameter);
int sqlType = parameter.getDataType().getDataType(c).getSQLType();
switch (c.dialect().family()) {
/* [pro] xx
xx xxx xxxx xxxx xxxxxxx xxxxx xxxxxx xxxxx xx xxxx
xx xxxx xxx xxxx xxxx
xxxx xxxxxxx x
xx xxxxxxxx xx xxxxxxxxxxxxx x
xxxxxxxxxxxx xxxxxx x xxxxx
xxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxx xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx
x
xxxx xx xxxxxxxx xx xxxxxxxxxxxx x
xxxxxxxxxxxxxx xxxxxx x xxxxxxxxxxxxxxxxxxxxx
xxxxxxxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
x
xx xxx xxxxxxx xxxxxxxxx xx xxx xx xxxxxxxx x xxxx
xx xxxxxxx
xxxx x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx
x
xxxxxx
x
xx [/pro] */
default: {
statement.registerOutParameter(index, sqlType);
break;
}
}
registerOutParameter(c, statement, parameter);
}
}
}
private final <U> void registerOutParameter(Configuration c, CallableStatement statement, Parameter<U> parameter) throws SQLException {
parameter.getBinding().register(new DefaultBindingRegisterContext<U>(c, statement, parameterIndexes.get(parameter)));
}
// ------------------------------------------------------------------------
// Fetch routine results
// ------------------------------------------------------------------------

View File

@ -0,0 +1,109 @@
/**
* 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.util.HashMap;
import java.util.Map;
import org.jooq.Configuration;
import org.jooq.SQLDialect;
import org.jooq.Scope;
import org.jooq.conf.Settings;
/**
* @author Lukas Eder
*/
abstract class AbstractScope implements Scope {
private final Configuration configuration;
private final Map<Object, Object> data;
AbstractScope(Configuration configuration) {
this.data = new HashMap<Object, Object>();
// The Configuration can be null when unattached objects are
// executed or when unattached Records are stored...
if (configuration == null) {
configuration = new DefaultConfiguration();
}
this.configuration = configuration;
}
// ------------------------------------------------------------------------
// XXX Scope API
// ------------------------------------------------------------------------
@Override
public final Configuration configuration() {
return configuration;
}
@Override
public final Settings settings() {
return Utils.settings(configuration());
}
@Override
public final SQLDialect dialect() {
return Utils.configuration(configuration()).dialect();
}
@Override
public final SQLDialect family() {
return dialect().family();
}
@Override
public final Map<Object, Object> data() {
return data;
}
@Override
public final Object data(Object key) {
return data.get(key);
}
@Override
public final Object data(Object key, Object value) {
return data.put(key, value);
}
}

View File

@ -183,7 +183,7 @@ xxxxxx xxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxxxxxx
xxxxxxxxx
xxxxxxxxxxx
xxxxxx xxxxx xxxx xxxxxxxxxxxxxxxxxx xxxxxx xxxxxx xxxxxxxxxxxx x
xxxxxxxxxxxxxxx xxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx
x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

View File

@ -1471,7 +1471,9 @@ class CursorImpl<R extends Record> implements Cursor<R> {
* Utility method to prevent unnecessary unchecked conversions
*/
private final <T> void setValue(AbstractRecord record, Field<T> field, int index) throws SQLException {
T value = Utils.getFromResultSet(ctx, field, index + 1);
DefaultBindingGetResultSetContext<T> out = new DefaultBindingGetResultSetContext<T>(ctx.configuration(), ctx.resultSet(), index + 1);
field.getBinding().get(out);
T value = out.value();
record.values[index] = value;
record.originals[index] = value;

View File

@ -0,0 +1,115 @@
/**
* 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

@ -40,364 +40,28 @@
*/
package org.jooq.impl;
import static java.util.Arrays.asList;
// ...
// ...
// ...
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
import static org.jooq.impl.DefaultExecuteContext.localTargetConnection;
import static org.jooq.tools.reflect.Reflect.on;
import static org.jooq.util.postgres.PostgresUtils.toPGArrayString;
import static org.jooq.util.postgres.PostgresUtils.toPGInterval;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.Arrays;
import java.util.UUID;
// ...
import org.jooq.BindContext;
import org.jooq.Configuration;
import org.jooq.Converter;
import org.jooq.EnumType;
import org.jooq.Field;
import org.jooq.SQLDialect;
import org.jooq.UDTRecord;
import org.jooq.exception.SQLDialectNotSupportedException;
import org.jooq.tools.Convert;
import org.jooq.tools.JooqLogger;
import org.jooq.tools.jdbc.MockArray;
import org.jooq.types.DayToSecond;
import org.jooq.types.UByte;
import org.jooq.types.UInteger;
import org.jooq.types.ULong;
import org.jooq.types.UShort;
import org.jooq.types.YearToMonth;
/**
* @author Lukas Eder
*/
class DefaultBindContext extends AbstractBindContext {
private static final JooqLogger log = JooqLogger.getLogger(DefaultBindContext.class);
DefaultBindContext(Configuration configuration, PreparedStatement stmt) {
super(configuration, stmt);
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({ "unchecked" })
protected final BindContext bindValue0(Object value, Field<?> field) throws SQLException {
SQLDialect dialect = configuration.dialect();
// [#650] [#3108] Use the Field's Converter before actually binding any value
Converter<?, ?> converter = field.getConverter();
Class<?> type = converter.fromType();
value = ((Converter) converter).to(value);
if (log.isTraceEnabled()) {
if (value != null && value.getClass().isArray() && value.getClass() != byte[].class) {
log.trace("Binding variable " + peekIndex(), Arrays.asList((Object[]) value) + " (" + type + ")");
}
else {
log.trace("Binding variable " + peekIndex(), value + " (" + type + ")");
}
}
// Setting null onto a prepared statement is subtly different for every
// SQL dialect. See the following section for details
if (value == null) {
int sqlType = DefaultDataType.getDataType(dialect, type).getSQLType();
/* [pro] xx
xx xxxxxxxxxxxx xxxxx xxxxx xxxx xx xx xxxxx xxxx xxxxx xxxx xxxx
xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxx xxxxxxxx x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxx
x
xxxx
xx [/pro] */
// [#1126] Oracle's UDTs need to be bound with their type name
if (UDTRecord.class.isAssignableFrom(type)) {
String typeName = Utils.newRecord(false, (Class<UDTRecord<?>>) type)
.<RuntimeException>operate(null)
.getUDT()
.getName();
stmt.setNull(nextIndex(), sqlType, typeName);
}
// [#1225] [#1227] TODO Put this logic into DataType
// Some dialects have trouble binding binary data as BLOB
else if (asList(POSTGRES).contains(configuration.dialect()) && sqlType == Types.BLOB) {
stmt.setNull(nextIndex(), Types.BINARY);
}
/* [pro] xx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxx x
xx xxxx xxxxxxxxxx xxxx xx xxxx xxxxxx xxxx xxx xxx xxxxxxxxx xxxxxx
xx xxxxxxxxxxx xxxxx xxxxxxx xxx xxxxxxx
xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxx xxxxxxxxx x
xxxx xxxxxxxxxxxxx
xxxx xxxxxxxxxxxxxxxx
xxxx xxxxxxxxxxxxxxxxxxxx
xxxx xxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx
xxxxxx
xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx
xxxxxx
x
x
xx xxxxxxx xxxxxxx xxx xxx xxxxxx xxxxxx xxxx xxx xxxx xxxxxxxx xxx xxx xxxx xxxxxx
xx xxxxxx xxx xxx xxxxxxx xxxxx
xxxx xx xxxxxxxx xx xxxxxxxxxxxxx xx xxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx
x
xx [/pro] */
// All other types can be set to null if the JDBC type is known
else if (sqlType != Types.OTHER) {
stmt.setNull(nextIndex(), sqlType);
}
/* [pro] xx
xx xxxxxx xxx xxx xxxxxxx xxxxxxx xxxxx xxxxxx xx xxx xx xxxx
xx xxxxxxxxxxx xxx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx
x
xx xxxxxx xxx xxxxxxx xxxxxxx xxxxx xxx xx xxx xx xxxx xxxxx xxxxxxx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx
x
xx [/pro] */
// [#729] In the absence of the correct JDBC type, try setObject
else {
stmt.setObject(nextIndex(), null);
}
}
else {
// Try to infer the bind value type from the actual bind value if possible.
if (type == Object.class) {
type = value.getClass();
}
if (type == Blob.class) {
stmt.setBlob(nextIndex(), (Blob) value);
}
else if (type == Boolean.class) {
/* [pro] xx
xx xx xxxxxx xxxxxx xxxxxx xx xxxxx xxxxx xxxxx xx xxxxxxxxx xx xxxxxxxxxx xx xxxxxxx xxxxxxx
xx xxxxxxxxxxxxxxxxx xx xxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxx x x x xxx
xxxx
xx [/pro] */
stmt.setBoolean(nextIndex(), (Boolean) value);
}
else if (type == BigDecimal.class) {
if (asList(SQLITE).contains(dialect.family())) {
stmt.setString(nextIndex(), value.toString());
}
else {
stmt.setBigDecimal(nextIndex(), (BigDecimal) value);
}
}
else if (type == BigInteger.class) {
if (asList(SQLITE).contains(dialect.family())) {
stmt.setString(nextIndex(), value.toString());
}
else {
stmt.setBigDecimal(nextIndex(), new BigDecimal((BigInteger) value));
}
}
else if (type == Byte.class) {
stmt.setByte(nextIndex(), (Byte) value);
}
else if (type == byte[].class) {
stmt.setBytes(nextIndex(), (byte[]) value);
}
else if (type == Clob.class) {
stmt.setClob(nextIndex(), (Clob) value);
}
else if (type == Double.class) {
stmt.setDouble(nextIndex(), (Double) value);
}
else if (type == Float.class) {
stmt.setFloat(nextIndex(), (Float) value);
}
else if (type == Integer.class) {
stmt.setInt(nextIndex(), (Integer) value);
}
else if (type == Long.class) {
/* [pro] xx
xx xxxxxxxxxxxxxxxxx xx xxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
xxxx
xx [/pro] */
stmt.setLong(nextIndex(), (Long) value);
}
else if (type == Short.class) {
stmt.setShort(nextIndex(), (Short) value);
}
else if (type == String.class) {
stmt.setString(nextIndex(), (String) value);
}
// There is potential for trouble when binding date time as such
// -------------------------------------------------------------
else if (type == Date.class) {
if (dialect == SQLITE) {
stmt.setString(nextIndex(), ((Date) value).toString());
}
else {
stmt.setDate(nextIndex(), (Date) value);
}
}
else if (type == Time.class) {
if (dialect == SQLITE) {
stmt.setString(nextIndex(), ((Time) value).toString());
}
else {
stmt.setTime(nextIndex(), (Time) value);
}
}
else if (type == Timestamp.class) {
if (dialect == SQLITE) {
stmt.setString(nextIndex(), ((Timestamp) value).toString());
}
else {
stmt.setTimestamp(nextIndex(), (Timestamp) value);
}
}
// [#566] Interval data types are best bound as Strings
else if (type == YearToMonth.class) {
if (dialect == POSTGRES) {
stmt.setObject(nextIndex(), toPGInterval((YearToMonth) value));
}
else {
stmt.setString(nextIndex(), value.toString());
}
}
else if (type == DayToSecond.class) {
if (dialect == POSTGRES) {
stmt.setObject(nextIndex(), toPGInterval((DayToSecond) value));
}
else {
stmt.setString(nextIndex(), value.toString());
}
}
else if (type == UByte.class) {
stmt.setShort(nextIndex(), ((UByte) value).shortValue());
}
else if (type == UShort.class) {
stmt.setInt(nextIndex(), ((UShort) value).intValue());
}
else if (type == UInteger.class) {
/* [pro] xx
xx xxxxxxxxxxxxxxxxx xx xxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
xxxx
xx [/pro] */
stmt.setLong(nextIndex(), ((UInteger) value).longValue());
}
else if (type == ULong.class) {
/* [pro] xx
xx xxxxxxxxxxxxxxxxx xx xxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
xxxx
xx [/pro] */
stmt.setBigDecimal(nextIndex(), new BigDecimal(value.toString()));
}
else if (type == UUID.class) {
switch (dialect.family()) {
// [#1624] Some JDBC drivers natively support the
// java.util.UUID data type
case H2:
case POSTGRES: {
stmt.setObject(nextIndex(), value);
break;
}
/* [pro] xx
xx xxxxx xxx xxxxxxxx xxxx xxxx xxxxx xx xx xxxx xxxx xxxxxxxx
xx xxxx xx xxxx xxxxxxxxxx xxxxxxx xxxx xxxxxxxxxxxxxxxxxx
xxxx xxxxxxxxxx
xxxx xxxxxxx
xx [/pro] */
// Most databases don't have such a type. In this case, jOOQ
// simulates the type
default: {
stmt.setString(nextIndex(), value.toString());
break;
}
}
}
// The type byte[] is handled earlier. byte[][] can be handled here
else if (type.isArray()) {
switch (dialect) {
case POSTGRES: {
stmt.setString(nextIndex(), toPGArrayString((Object[]) value));
break;
}
case HSQLDB: {
Object[] a = (Object[]) value;
Class<?> t = type;
// [#2325] Some array types are not natively supported by HSQLDB
// More integration tests are probably needed...
if (type == UUID[].class) {
a = Convert.convertArray(a, String[].class);
t = String[].class;
}
stmt.setArray(nextIndex(), new MockArray(dialect, a, t));
break;
}
case H2: {
stmt.setObject(nextIndex(), value);
break;
}
default:
throw new SQLDialectNotSupportedException("Cannot bind ARRAY types in dialect " + dialect);
}
}
/* [pro] xx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxx xxxxxxxxxxx x xxxxxxxxxxxxxxxx xxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x
xx [/pro] */
else if (EnumType.class.isAssignableFrom(type)) {
stmt.setString(nextIndex(), ((EnumType) value).getLiteral());
}
else {
stmt.setObject(nextIndex(), value);
}
}
((Field<Object>) field).getBinding().set(
new DefaultBindingSetStatementContext<Object>(configuration(), stmt, nextIndex(), value)
);
return this;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
/**
* 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

@ -0,0 +1,82 @@
/**
* 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.ResultSet;
import org.jooq.BindingGetResultSetContext;
import org.jooq.Configuration;
/**
* @author Lukas Eder
*/
class DefaultBindingGetResultSetContext<T> extends AbstractScope implements BindingGetResultSetContext<T> {
private final ResultSet resultSet;
private final int index;
private T value;
DefaultBindingGetResultSetContext(Configuration configuration, ResultSet resultSet, int index) {
super(configuration);
this.resultSet = resultSet;
this.index = index;
}
@Override
public final ResultSet resultSet() {
return resultSet;
}
@Override
public final int index() {
return index;
}
@Override
public final void value(T v) {
this.value = v;
}
final T value() {
return value;
}
}

View File

@ -0,0 +1,75 @@
/**
* 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.SQLInput;
import org.jooq.BindingGetSQLInputContext;
import org.jooq.Configuration;
/**
* @author Lukas Eder
*/
class DefaultBindingGetSQLInputContext<T> extends AbstractScope implements BindingGetSQLInputContext<T> {
private final SQLInput input;
private T value;
DefaultBindingGetSQLInputContext(Configuration configuration, SQLInput input) {
super(configuration);
this.input = input;
}
@Override
public final SQLInput input() {
return input;
}
@Override
public final void value(T v) {
this.value = v;
}
final T value() {
return value;
}
}

View File

@ -0,0 +1,82 @@
/**
* 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.CallableStatement;
import org.jooq.BindingGetStatementContext;
import org.jooq.Configuration;
/**
* @author Lukas Eder
*/
class DefaultBindingGetStatementContext<T> extends AbstractScope implements BindingGetStatementContext<T> {
private final CallableStatement statement;
private final int index;
private T value;
DefaultBindingGetStatementContext(Configuration configuration, CallableStatement statement, int index) {
super(configuration);
this.statement = statement;
this.index = index;
}
@Override
public final CallableStatement statement() {
return statement;
}
@Override
public final int index() {
return index;
}
@Override
public final void value(T v) {
this.value = v;
}
final T value() {
return value;
}
}

View File

@ -0,0 +1,72 @@
/**
* 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.CallableStatement;
import org.jooq.BindingRegisterContext;
import org.jooq.Configuration;
/**
* @author Lukas Eder
*/
class DefaultBindingRegisterContext<T> extends AbstractScope implements BindingRegisterContext<T> {
private final CallableStatement statement;
private final int index;
DefaultBindingRegisterContext(Configuration configuration, CallableStatement statement, int index) {
super(configuration);
this.statement = statement;
this.index = index;
}
@Override
public final CallableStatement statement() {
return statement;
}
@Override
public final int index() {
return index;
}
}

View File

@ -0,0 +1,71 @@
/**
* 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.BindingSQLContext;
import org.jooq.Configuration;
import org.jooq.RenderContext;
/**
* @author Lukas Eder
*/
class DefaultBindingSQLContext<T> extends AbstractScope implements BindingSQLContext<T> {
private final RenderContext render;
private final T value;
DefaultBindingSQLContext(Configuration configuration, RenderContext render, T value) {
super(configuration);
this.render = render;
this.value = value;
}
@Override
public final RenderContext render() {
return render;
}
@Override
public final T value() {
return value;
}
}

View File

@ -0,0 +1,72 @@
/**
* 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.SQLOutput;
import org.jooq.BindingSetSQLOutputContext;
import org.jooq.Configuration;
/**
* @author Lukas Eder
*/
class DefaultBindingSetSQLOutputContext<T> extends AbstractScope implements BindingSetSQLOutputContext<T> {
private final SQLOutput output;
private final T value;
DefaultBindingSetSQLOutputContext(Configuration configuration, SQLOutput output, T value) {
super(configuration);
this.output = output;
this.value = value;
}
@Override
public final SQLOutput output() {
return output;
}
@Override
public final T value() {
return value;
}
}

View File

@ -0,0 +1,79 @@
/**
* 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.PreparedStatement;
import org.jooq.BindingSetStatementContext;
import org.jooq.Configuration;
/**
* @author Lukas Eder
*/
class DefaultBindingSetStatementContext<T> extends AbstractScope implements BindingSetStatementContext<T> {
private final PreparedStatement statement;
private final int index;
private final T value;
DefaultBindingSetStatementContext(Configuration configuration, PreparedStatement statement, int index, T value) {
super(configuration);
this.statement = statement;
this.index = index;
this.value = value;
}
@Override
public final PreparedStatement statement() {
return statement;
}
@Override
public final int index() {
return index;
}
@Override
public final T value() {
return value;
}
}

View File

@ -220,7 +220,7 @@ import org.jooq.tools.reflect.ReflectException;
* @author Lukas Eder
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DefaultDSLContext implements DSLContext, Serializable {
public class DefaultDSLContext extends AbstractScope implements DSLContext, Serializable {
/**
* Generated UID
@ -228,8 +228,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
private static final long serialVersionUID = 2681360188806309513L;
private static final JooqLogger log = JooqLogger.getLogger(DefaultDSLContext.class);
private final Configuration configuration;
// -------------------------------------------------------------------------
// XXX Constructors
// -------------------------------------------------------------------------
@ -267,48 +265,21 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
public DefaultDSLContext(Configuration configuration) {
// The Configuration can be null when unattached Query objects are
// executed or when unattached Records are stored...
if (configuration == null) {
configuration = new DefaultConfiguration();
}
this.configuration = configuration;
super(configuration);
}
// -------------------------------------------------------------------------
// XXX Configuration API
// -------------------------------------------------------------------------
@Override
public Configuration configuration() {
return configuration;
}
@Override
public Settings settings() {
return Utils.settings(configuration());
}
@Override
public SQLDialect dialect() {
return Utils.configuration(configuration()).dialect();
}
@Override
public SQLDialect family() {
return dialect().family();
}
@Override
public Schema map(Schema schema) {
return Utils.getMappedSchema(configuration, schema);
return Utils.getMappedSchema(configuration(), schema);
}
@Override
public <R extends Record> Table<R> map(Table<R> table) {
return Utils.getMappedTable(configuration, table);
return Utils.getMappedTable(configuration(), table);
}
// -------------------------------------------------------------------------
@ -317,7 +288,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Meta meta() {
return new MetaImpl(configuration);
return new MetaImpl(configuration());
}
// -------------------------------------------------------------------------
@ -328,7 +299,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
public <T> T transactionResult(TransactionalCallable<T> transactional) {
T result = null;
DefaultTransactionContext ctx = new DefaultTransactionContext(configuration.derive());
DefaultTransactionContext ctx = new DefaultTransactionContext(configuration().derive());
TransactionProvider provider = ctx.configuration().transactionProvider();
try {
@ -379,7 +350,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public RenderContext renderContext() {
return new DefaultRenderContext(configuration);
return new DefaultRenderContext(configuration());
}
@Override
@ -419,7 +390,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
final Map<String, Param<?>> extractParams0(QueryPart part, boolean includeInlinedParams) {
ParamCollector collector = new ParamCollector(configuration, includeInlinedParams);
ParamCollector collector = new ParamCollector(configuration(), includeInlinedParams);
collector.visit(part);
return Collections.unmodifiableMap(collector.result);
}
@ -431,7 +402,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public BindContext bindContext(PreparedStatement stmt) {
return new DefaultBindContext(configuration, stmt);
return new DefaultBindContext(configuration(), stmt);
}
@Override
@ -452,7 +423,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public void attach(Collection<? extends Attachable> attachables) {
for (Attachable attachable : attachables) {
attachable.attach(configuration);
attachable.attach(configuration());
}
}
@ -462,7 +433,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public <R extends TableRecord<R>> LoaderOptionsStep<R> loadInto(Table<R> table) {
return new LoaderImpl<R>(configuration, table);
return new LoaderImpl<R>(configuration(), table);
}
// -------------------------------------------------------------------------
@ -486,7 +457,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@SuppressWarnings("deprecation")
Query query(org.jooq.Template template, Object... parameters) {
return new SQLQuery(configuration, queryPart(template, parameters));
return new SQLQuery(configuration(), queryPart(template, parameters));
}
@Override
@ -636,7 +607,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@SuppressWarnings("deprecation")
ResultQuery<Record> resultQuery(org.jooq.Template template, Object... parameters) {
return new SQLResultQuery(configuration, queryPart(template, parameters));
return new SQLResultQuery(configuration(), queryPart(template, parameters));
}
// -------------------------------------------------------------------------
@ -726,7 +697,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Cursor<Record> fetchLazy(ResultSet rs) {
try {
return fetchLazy(rs, new MetaDataFieldProvider(configuration, rs.getMetaData()).getFields());
return fetchLazy(rs, new MetaDataFieldProvider(configuration(), rs.getMetaData()).getFields());
}
catch (SQLException e) {
throw new DataAccessException("Error while accessing ResultSet meta data", e);
@ -735,7 +706,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Cursor<Record> fetchLazy(ResultSet rs, Field<?>... fields) {
ExecuteContext ctx = new DefaultExecuteContext(configuration);
ExecuteContext ctx = new DefaultExecuteContext(configuration());
ExecuteListener listener = new ExecuteListeners(ctx);
ctx.resultSet(rs);
@ -835,7 +806,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Result<Record> fetchFromStringData(List<String[]> data) {
if (data.size() == 0) {
return new ResultImpl<Record>(configuration);
return new ResultImpl<Record>(configuration());
}
else {
List<Field<?>> fields = new ArrayList<Field<?>>();
@ -844,7 +815,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
fields.add(fieldByName(String.class, name));
}
Result<Record> result = new ResultImpl<Record>(configuration, fields);
Result<Record> result = new ResultImpl<Record>(configuration(), fields);
if (data.size() > 1) {
for (String[] values : data.subList(1, data.size())) {
@ -869,52 +840,52 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public WithAsStep with(String alias) {
return new WithImpl(configuration, false).with(alias);
return new WithImpl(configuration(), false).with(alias);
}
@Override
public WithAsStep with(String alias, String... fieldAliases) {
return new WithImpl(configuration, false).with(alias, fieldAliases);
return new WithImpl(configuration(), false).with(alias, fieldAliases);
}
@Override
public WithStep with(CommonTableExpression<?>... tables) {
return new WithImpl(configuration, false).with(tables);
return new WithImpl(configuration(), false).with(tables);
}
@Override
public WithAsStep withRecursive(String alias) {
return new WithImpl(configuration, true).with(alias);
return new WithImpl(configuration(), true).with(alias);
}
@Override
public WithAsStep withRecursive(String alias, String... fieldAliases) {
return new WithImpl(configuration, true).with(alias, fieldAliases);
return new WithImpl(configuration(), true).with(alias, fieldAliases);
}
@Override
public WithStep withRecursive(CommonTableExpression<?>... tables) {
return new WithImpl(configuration, true).with(tables);
return new WithImpl(configuration(), true).with(tables);
}
@Override
public <R extends Record> SelectWhereStep<R> selectFrom(Table<R> table) {
SelectWhereStep<R> result = DSL.selectFrom(table);
result.attach(configuration);
result.attach(configuration());
return result;
}
@Override
public SelectSelectStep<Record> select(Collection<? extends Field<?>> fields) {
SelectSelectStep<Record> result = DSL.select(fields);
result.attach(configuration);
result.attach(configuration());
return result;
}
@Override
public SelectSelectStep<Record> select(Field<?>... fields) {
SelectSelectStep<Record> result = DSL.select(fields);
result.attach(configuration);
result.attach(configuration());
return result;
}
@ -1057,14 +1028,14 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public SelectSelectStep<Record> selectDistinct(Collection<? extends Field<?>> fields) {
SelectSelectStep<Record> result = DSL.selectDistinct(fields);
result.attach(configuration);
result.attach(configuration());
return result;
}
@Override
public SelectSelectStep<Record> selectDistinct(Field<?>... fields) {
SelectSelectStep<Record> result = DSL.selectDistinct(fields);
result.attach(configuration);
result.attach(configuration());
return result;
}
@ -1207,42 +1178,42 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public SelectSelectStep<Record1<Integer>> selectZero() {
SelectSelectStep<Record1<Integer>> result = DSL.selectZero();
result.attach(configuration);
result.attach(configuration());
return result;
}
@Override
public SelectSelectStep<Record1<Integer>> selectOne() {
SelectSelectStep<Record1<Integer>> result = DSL.selectOne();
result.attach(configuration);
result.attach(configuration());
return result;
}
@Override
public SelectSelectStep<Record1<Integer>> selectCount() {
SelectSelectStep<Record1<Integer>> result = DSL.selectCount();
result.attach(configuration);
result.attach(configuration());
return result;
}
@Override
public SelectQuery<Record> selectQuery() {
return new SelectQueryImpl(null, configuration);
return new SelectQueryImpl(null, configuration());
}
@Override
public <R extends Record> SelectQuery<R> selectQuery(TableLike<R> table) {
return new SelectQueryImpl<R>(null, configuration, table);
return new SelectQueryImpl<R>(null, configuration(), table);
}
@Override
public <R extends Record> InsertQuery<R> insertQuery(Table<R> into) {
return new InsertQueryImpl<R>(configuration, into);
return new InsertQueryImpl<R>(configuration(), into);
}
@Override
public <R extends Record> InsertSetStep<R> insertInto(Table<R> into) {
return new InsertImpl(configuration, into, Collections.<Field<?>>emptyList());
return new InsertImpl(configuration(), into, Collections.<Field<?>>emptyList());
}
// [jooq-tools] START [insert]
@ -1250,160 +1221,160 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1> InsertValuesStep1<R, T1> insertInto(Table<R> into, Field<T1> field1) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2> InsertValuesStep2<R, T1, T2> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3> InsertValuesStep3<R, T1, T2, T3> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4> InsertValuesStep4<R, T1, T2, T3, T4> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5> InsertValuesStep5<R, T1, T2, T3, T4, T5> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6> InsertValuesStep6<R, T1, T2, T3, T4, T5, T6> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7> InsertValuesStep7<R, T1, T2, T3, T4, T5, T6, T7> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8> InsertValuesStep8<R, T1, T2, T3, T4, T5, T6, T7, T8> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9> InsertValuesStep9<R, T1, T2, T3, T4, T5, T6, T7, T8, T9> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> InsertValuesStep10<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> InsertValuesStep11<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> InsertValuesStep12<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> InsertValuesStep13<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> InsertValuesStep14<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> InsertValuesStep15<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> InsertValuesStep16<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { 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
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> InsertValuesStep17<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { 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
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> InsertValuesStep18<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> InsertValuesStep19<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> InsertValuesStep20<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> InsertValuesStep21<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21 }));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> InsertValuesStep22<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> insertInto(Table<R> into, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21, Field<T22> field22) {
return new InsertImpl(configuration, into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22 }));
return new InsertImpl(configuration(), into, Arrays.asList(new Field[] { field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22 }));
}
// [jooq-tools] END [insert]
@Override
public <R extends Record> InsertValuesStepN<R> insertInto(Table<R> into, Field<?>... fields) {
return new InsertImpl(configuration, into, Arrays.asList(fields));
return new InsertImpl(configuration(), into, Arrays.asList(fields));
}
@Override
public <R extends Record> InsertValuesStepN<R> insertInto(Table<R> into, Collection<? extends Field<?>> fields) {
return new InsertImpl(configuration, into, fields);
return new InsertImpl(configuration(), into, fields);
}
@Override
public <R extends Record> UpdateQuery<R> updateQuery(Table<R> table) {
return new UpdateQueryImpl<R>(configuration, table);
return new UpdateQueryImpl<R>(configuration(), table);
}
@Override
public <R extends Record> UpdateSetFirstStep<R> update(Table<R> table) {
return new UpdateImpl<R>(configuration, table);
return new UpdateImpl<R>(configuration(), table);
}
@Override
public <R extends Record> MergeUsingStep<R> mergeInto(Table<R> table) {
return new MergeImpl(configuration, table);
return new MergeImpl(configuration(), table);
}
// [jooq-tools] START [merge]
@ -1411,133 +1382,133 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1> MergeKeyStep1<R, T1> mergeInto(Table<R> table, Field<T1> field1) {
return new MergeImpl(configuration, table, Arrays.asList(field1));
return new MergeImpl(configuration(), table, Arrays.asList(field1));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2> MergeKeyStep2<R, T1, T2> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3> MergeKeyStep3<R, T1, T2, T3> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4> MergeKeyStep4<R, T1, T2, T3, T4> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5> MergeKeyStep5<R, T1, T2, T3, T4, T5> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6> MergeKeyStep6<R, T1, T2, T3, T4, T5, T6> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7> MergeKeyStep7<R, T1, T2, T3, T4, T5, T6, T7> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8> MergeKeyStep8<R, T1, T2, T3, T4, T5, T6, T7, T8> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9> MergeKeyStep9<R, T1, T2, T3, T4, T5, T6, T7, T8, T9> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> MergeKeyStep10<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> MergeKeyStep11<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> MergeKeyStep12<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> MergeKeyStep13<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> MergeKeyStep14<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14));
return new MergeImpl(configuration(), table, 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
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> MergeKeyStep15<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15));
return new MergeImpl(configuration(), table, 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
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> MergeKeyStep16<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16));
return new MergeImpl(configuration(), table, 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
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> MergeKeyStep17<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17));
return new MergeImpl(configuration(), table, 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
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> MergeKeyStep18<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> MergeKeyStep19<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> MergeKeyStep20<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> MergeKeyStep21<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21));
}
@Generated("This method was generated using jOOQ-tools")
@Override
public <R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> MergeKeyStep22<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> mergeInto(Table<R> table, Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21, Field<T22> field22) {
return new MergeImpl(configuration, table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22));
return new MergeImpl(configuration(), table, Arrays.asList(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22));
}
// [jooq-tools] END [merge]
@ -1549,17 +1520,17 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public <R extends Record> MergeKeyStepN<R> mergeInto(Table<R> table, Collection<? extends Field<?>> fields) {
return new MergeImpl(configuration, table, fields);
return new MergeImpl(configuration(), table, fields);
}
@Override
public <R extends Record> DeleteQuery<R> deleteQuery(Table<R> table) {
return new DeleteQueryImpl<R>(configuration, table);
return new DeleteQueryImpl<R>(configuration(), table);
}
@Override
public <R extends Record> DeleteWhereStep<R> delete(Table<R> table) {
return new DeleteImpl<R>(configuration, table);
return new DeleteImpl<R>(configuration(), table);
}
// -------------------------------------------------------------------------
@ -1568,7 +1539,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Batch batch(Query... queries) {
return new BatchMultiple(configuration, queries);
return new BatchMultiple(configuration(), queries);
}
@Override
@ -1589,7 +1560,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public BatchBindStep batch(Query query) {
return new BatchSingle(configuration, query);
return new BatchSingle(configuration(), query);
}
@Override
@ -1609,7 +1580,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Batch batchStore(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration, Action.STORE, records);
return new BatchCRUD(configuration(), Action.STORE, records);
}
@Override
@ -1619,7 +1590,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Batch batchInsert(TableRecord<?>... records) {
return new BatchCRUD(configuration, Action.INSERT, records);
return new BatchCRUD(configuration(), Action.INSERT, records);
}
@Override
@ -1629,7 +1600,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Batch batchUpdate(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration, Action.UPDATE, records);
return new BatchCRUD(configuration(), Action.UPDATE, records);
}
@Override
@ -1639,7 +1610,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Batch batchDelete(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration, Action.DELETE, records);
return new BatchCRUD(configuration(), Action.DELETE, records);
}
@Override
@ -1658,7 +1629,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public CreateViewAsStep<Record> createView(Table<?> view, Field<?>... fields) {
return new CreateViewImpl<Record>(configuration, view, fields);
return new CreateViewImpl<Record>(configuration(), view, fields);
}
@Override
@ -1668,17 +1639,17 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public CreateTableAsStep<Record> createTable(Table<?> table) {
return new CreateTableImpl<Record>(configuration, table);
return new CreateTableImpl<Record>(configuration(), table);
}
@Override
public CreateIndexStep createIndex(String index) {
return new CreateIndexImpl(configuration, index);
return new CreateIndexImpl(configuration(), index);
}
@Override
public CreateSequenceFinalStep createSequence(Sequence<?> sequence) {
return new CreateSequenceImpl(configuration, sequence);
return new CreateSequenceImpl(configuration(), sequence);
}
@Override
@ -1688,7 +1659,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public <T extends Number> AlterSequenceRestartStep<T> alterSequence(Sequence<T> sequence) {
return new AlterSequenceImpl<T>(configuration, sequence);
return new AlterSequenceImpl<T>(configuration(), sequence);
}
@Override
@ -1698,7 +1669,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public AlterTableStep alterTable(Table<?> table) {
return new AlterTableImpl(configuration, table);
return new AlterTableImpl(configuration(), table);
}
@Override
@ -1708,7 +1679,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public DropViewFinalStep dropView(Table<?> table) {
return new DropViewImpl(configuration, table);
return new DropViewImpl(configuration(), table);
}
@Override
@ -1718,7 +1689,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public DropViewFinalStep dropViewIfExists(Table<?> table) {
return new DropViewImpl(configuration, table, true);
return new DropViewImpl(configuration(), table, true);
}
@Override
@ -1728,7 +1699,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public DropTableStep dropTable(Table<?> table) {
return new DropTableImpl(configuration, table);
return new DropTableImpl(configuration(), table);
}
@Override
@ -1738,7 +1709,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public DropTableStep dropTableIfExists(Table<?> table) {
return new DropTableImpl(configuration, table, true);
return new DropTableImpl(configuration(), table, true);
}
@Override
@ -1748,17 +1719,17 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public DropIndexFinalStep dropIndex(String index) {
return new DropIndexImpl(configuration, index);
return new DropIndexImpl(configuration(), index);
}
@Override
public DropIndexFinalStep dropIndexIfExists(String index) {
return new DropIndexImpl(configuration, index, true);
return new DropIndexImpl(configuration(), index, true);
}
@Override
public DropSequenceFinalStep dropSequence(Sequence<?> sequence) {
return new DropSequenceImpl(configuration, sequence);
return new DropSequenceImpl(configuration(), sequence);
}
@Override
@ -1768,7 +1739,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public DropSequenceFinalStep dropSequenceIfExists(Sequence<?> sequence) {
return new DropSequenceImpl(configuration, sequence, true);
return new DropSequenceImpl(configuration(), sequence, true);
}
@Override
@ -1778,7 +1749,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public <R extends Record> TruncateIdentityStep<R> truncate(Table<R> table) {
return new TruncateImpl<R>(configuration, table);
return new TruncateImpl<R>(configuration(), table);
}
// -------------------------------------------------------------------------
@ -1787,7 +1758,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public BigInteger lastID() {
switch (configuration.dialect().family()) {
switch (configuration().dialect().family()) {
case DERBY: {
Field<BigInteger> field = field("identity_val_local()", BigInteger.class);
return select(field).fetchOne(field);
@ -1831,7 +1802,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
xx [/pro] */
default:
throw new SQLDialectNotSupportedException("identity functionality not supported by " + configuration.dialect());
throw new SQLDialectNotSupportedException("identity functionality not supported by " + configuration().dialect());
}
}
@ -1863,7 +1834,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public Record newRecord(Field<?>... fields) {
return Utils.newRecord(false, RecordImpl.class, fields, configuration).<RuntimeException>operate(null);
return Utils.newRecord(false, RecordImpl.class, fields, configuration()).<RuntimeException>operate(null);
}
// [jooq-tools] START [newRecord]
@ -2004,17 +1975,17 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public <R extends UDTRecord<R>> R newRecord(UDT<R> type) {
return Utils.newRecord(false, type, configuration).<RuntimeException>operate(null);
return Utils.newRecord(false, type, configuration()).<RuntimeException>operate(null);
}
@Override
public <R extends Record> R newRecord(Table<R> table) {
return Utils.newRecord(false, table, configuration).<RuntimeException>operate(null);
return Utils.newRecord(false, table, configuration()).<RuntimeException>operate(null);
}
@Override
public <R extends Record> R newRecord(Table<R> table, final Object source) {
return Utils.newRecord(false, table, configuration)
return Utils.newRecord(false, table, configuration())
.operate(new RecordOperation<R, RuntimeException>() {
@Override
@ -2027,12 +1998,12 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public <R extends Record> Result<R> newResult(Table<R> table) {
return new ResultImpl<R>(configuration, table.fields());
return new ResultImpl<R>(configuration(), table.fields());
}
@Override
public Result<Record> newResult(Field<?>... fields) {
return new ResultImpl<Record>(configuration, fields);
return new ResultImpl<Record>(configuration(), fields);
}
// [jooq-tools] START [newResult]
@ -2180,7 +2151,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
final Configuration previous = Utils.getConfiguration(query);
try {
query.attach(configuration);
query.attach(configuration());
return query.fetch();
}
finally {
@ -2193,7 +2164,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
final Configuration previous = Utils.getConfiguration(query);
try {
query.attach(configuration);
query.attach(configuration());
return query.fetchLazy();
}
finally {
@ -2206,7 +2177,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
final Configuration previous = Utils.getConfiguration(query);
try {
query.attach(configuration);
query.attach(configuration());
return query.fetchMany();
}
finally {
@ -2219,7 +2190,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
final Configuration previous = Utils.getConfiguration(query);
try {
query.attach(configuration);
query.attach(configuration());
return query.fetchOne();
}
finally {
@ -2232,7 +2203,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
final Configuration previous = Utils.getConfiguration(query);
try {
query.attach(configuration);
query.attach(configuration());
return value1(fetchOne(query));
}
finally {
@ -2275,7 +2246,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
final Configuration previous = Utils.getConfiguration(query);
try {
query.attach(configuration);
query.attach(configuration());
return query.execute();
}
finally {
@ -2383,6 +2354,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public String toString() {
return configuration.toString();
return configuration().toString();
}
}

View File

@ -392,7 +392,7 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
return this;
}
SQLDialect family = configuration.dialect().family();
SQLDialect family = family();
// Quoting is needed when explicitly requested...
boolean needsQuote =

View File

@ -41,42 +41,19 @@
package org.jooq.impl;
import org.jooq.Configuration;
import org.jooq.SQLDialect;
import org.jooq.Transaction;
import org.jooq.TransactionContext;
import org.jooq.conf.Settings;
/**
* @author Lukas Eder
*/
class DefaultTransactionContext implements TransactionContext {
class DefaultTransactionContext extends AbstractScope implements TransactionContext {
private final Configuration configuration;
Transaction transaction;
Exception cause;
DefaultTransactionContext(Configuration configuration) {
this.configuration = configuration;
}
@Override
public final Configuration configuration() {
return configuration;
}
@Override
public final Settings settings() {
return Utils.settings(configuration());
}
@Override
public final SQLDialect dialect() {
return Utils.configuration(configuration()).dialect();
}
@Override
public final SQLDialect family() {
return dialect().family();
super(configuration);
}
@Override

View File

@ -0,0 +1,63 @@
/**
* 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

@ -41,6 +41,7 @@
package org.jooq.impl;
import org.jooq.Binding;
import org.jooq.Clause;
import org.jooq.Configuration;
import org.jooq.Context;
@ -61,6 +62,7 @@ class ParameterImpl<T> extends AbstractQueryPart implements Parameter<T> {
private final String name;
private final DataType<T> type;
private final Converter<?, T> converter;
private final Binding<T> binding;
private final boolean isDefaulted;
@SuppressWarnings({ "unchecked", "rawtypes" })
@ -77,6 +79,8 @@ class ParameterImpl<T> extends AbstractQueryPart implements Parameter<T> {
: type instanceof ConvertedDataType
? ((ConvertedDataType<?, T>) type).converter()
: new IdentityConverter<T>((Class<T>) type.getType());
this.binding = new DefaultBinding(this.converter, type.isLob());
}
@Override
@ -89,6 +93,11 @@ class ParameterImpl<T> extends AbstractQueryPart implements Parameter<T> {
return converter;
}
@Override
public final Binding<T> getBinding() {
return binding;
}
@Override
public final DataType<T> getDataType() {
return type;

View File

@ -0,0 +1,102 @@
/**
* 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

@ -0,0 +1,94 @@
/**
* 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

@ -0,0 +1,107 @@
/**
* 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

@ -0,0 +1,115 @@
/**
* 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

@ -1071,7 +1071,7 @@ class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> implement
// --------------------------------------------
if (unionOpSize > 0) {
unionParenthesis(context, ")");
for (int i = 0; i < unionOpSize; i++) {
CombineOperator op = unionOp.get(i);

View File

@ -126,7 +126,9 @@ public class UDTRecordImpl<R extends UDTRecord<R>> extends AbstractRecord implem
}
private final <T> void setValue(Configuration configuration, SQLInput stream, Field<T> field) throws SQLException {
setValue(field, Utils.getFromSQLInput(configuration, stream, field));
DefaultBindingGetSQLInputContext<T> out = new DefaultBindingGetSQLInputContext<T>(configuration, stream);
field.getBinding().get(out);
setValue(field, out.value());
}
@Override
@ -137,7 +139,7 @@ public class UDTRecordImpl<R extends UDTRecord<R>> extends AbstractRecord implem
}
private final <T> void setValue(SQLOutput stream, Field<T> field) throws SQLException {
Utils.writeToSQLOutput(stream, field, getValue(field));
field.getBinding().set(new DefaultBindingSetSQLOutputContext<T>(localConfiguration(), stream, getValue(field)));
}
@Override

File diff suppressed because it is too large Load Diff

View File

@ -40,51 +40,10 @@
*/
package org.jooq.impl;
import static java.lang.Boolean.TRUE;
import static java.lang.Integer.toOctalString;
import static java.util.Arrays.asList;
// ...
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.HSQLDB;
// ...
// ...
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
import static org.jooq.conf.ParamType.NAMED;
import static org.jooq.conf.ParamType.NAMED_OR_INLINED;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.using;
import static org.jooq.impl.Utils.needsBackslashEscaping;
import static org.jooq.tools.StringUtils.leftPad;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
// ...
import org.jooq.BindContext;
import org.jooq.Context;
import org.jooq.Converter;
import org.jooq.DataType;
import org.jooq.EnumType;
import org.jooq.RenderContext;
import org.jooq.SQLDialect;
import org.jooq.Schema;
import org.jooq.UDTRecord;
import org.jooq.tools.StringUtils;
import org.jooq.types.Interval;
import org.jooq.conf.ParamType;
/**
* @author Lukas Eder
@ -92,7 +51,6 @@ import org.jooq.types.Interval;
class Val<T> extends AbstractParam<T> {
private static final long serialVersionUID = 6807729087019209084L;
private static final char[] HEX = "0123456789abcdef".toCharArray();
Val(T value, DataType<T> type) {
super(value, type);
@ -108,580 +66,22 @@ class Val<T> extends AbstractParam<T> {
@Override
public void accept(Context<?> ctx) {
if (ctx instanceof RenderContext)
toSQL0((RenderContext) ctx);
else
bind0((BindContext) ctx);
}
if (ctx instanceof RenderContext) {
ParamType paramType = ctx.paramType();
final void toSQL0(RenderContext context) {
if (isInline(ctx))
ctx.paramType(ParamType.INLINED);
// Casting can be enforced or prevented
switch (context.castMode()) {
case NEVER:
toSQL(context, value, getConverter());
return;
case ALWAYS:
toSQLCast(context);
return;
}
// See if we "should" cast, to stay on the safe side
if (shouldCast(context)) {
toSQLCast(context);
}
// Most RDBMS can infer types for bind values
else {
toSQL(context, value, getConverter());
}
}
private final boolean shouldCast(RenderContext context) {
// In default mode, casting is only done when parameters are NOT inlined
if (!isInline(context)) {
// Generated enums should not be cast...
if (!(value instanceof EnumType)) {
switch (context.configuration().dialect().family()) {
// These dialects can hardly detect the type of a bound constant.
/* [pro] xx
xxxx xxxx
xxxx xxxxxxxxx
xx [/pro] */
case DERBY:
case FIREBIRD:
// These dialects have some trouble, when they mostly get it right.
case H2:
case HSQLDB:
// [#1261] There are only a few corner-cases, where this is
// really needed. Check back on related CUBRID bugs
case CUBRID:
// [#1029] Postgres and [#632] Sybase need explicit casting
// in very rare cases.
/* [pro] xx
xxxx xxxxxxx
xx [/pro] */
case POSTGRES: {
return true;
}
}
}
}
// [#566] JDBC doesn't explicitly support interval data types. To be on
// the safe side, always cast these types in those dialects that support
// them
if (getDataType().isInterval()) {
switch (context.configuration().dialect().family()) {
/* [pro] xx
xxxx xxxxxxx
xx [/pro] */
case POSTGRES:
return true;
}
}
return false;
}
/**
* Render the bind variable including a cast, if necessary
*/
private final void toSQLCast(RenderContext context) {
DataType<T> dataType = getDataType(context.configuration());
DataType<T> type = dataType.getSQLDataType();
SQLDialect family = context.configuration().dialect().family();
// [#822] Some RDBMS need precision / scale information on BigDecimals
if (value != null && getType() == BigDecimal.class && asList(CUBRID, DERBY, FIREBIRD, HSQLDB).contains(family)) {
// Add precision / scale on BigDecimals
int scale = ((BigDecimal) value).scale();
int precision = scale + ((BigDecimal) value).precision();
// Firebird's max precision is 18
if (family == FIREBIRD) {
precision = Math.min(precision, 18);
}
toSQLCast(context, dataType, 0, precision, scale);
}
// [#1028] Most databases don't know an OTHER type (except H2, HSQLDB).
else if (SQLDataType.OTHER == type) {
// If the bind value is set, it can be used to derive the cast type
if (value != null) {
toSQLCast(context, DefaultDataType.getDataType(family, value.getClass()), 0, 0, 0);
}
// [#632] [#722] Current integration tests show that Ingres and
// Sybase can do without casting in most cases.
else if (asList().contains(family)) {
context.sql(getBindVariable(context));
}
// Derby and DB2 must have a type associated with NULL. Use VARCHAR
// as a workaround. That's probably not correct in all cases, though
else {
toSQLCast(context, DefaultDataType.getDataType(family, String.class), 0, 0, 0);
}
}
// [#1029] Postgres generally doesn't need the casting. Only in the
// above case where the type is OTHER
// [#1125] Also with temporal data types, casting is needed some times
// [#1130] TODO type can be null for ARRAY types, etc.
else if (family == POSTGRES && (type == null || !type.isTemporal())) {
toSQL(context, value, getConverter());
}
// [#1727] VARCHAR types should be cast to their actual lengths in some
// dialects
else if ((type == SQLDataType.VARCHAR || type == SQLDataType.CHAR) && asList(FIREBIRD).contains(family)) {
toSQLCast(context, dataType, getValueLength(), 0, 0);
}
/* [pro] xx
xx xxxxxxx xxxx xxxx xxxxx xxxxxx xxx xx xxxx xx xxx xxxxxx xx xxxx xxxxxxxx
xxxx xx xxxxx xx xxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxxxxxx xxxxxxxxx xx xx xxx
x
xx [/pro] */
// In all other cases, the bind variable can be cast normally
else {
toSQLCast(context, dataType, dataType.length(), dataType.precision(), dataType.scale());
}
}
private final int getValueLength() {
String string = (String) value;
if (string == null) {
return 1;
new DefaultBinding(getConverter(), getDataType().isLob(), getParamName()).sql(new DefaultBindingSQLContext<T>(ctx.configuration(), (RenderContext) ctx, value));
ctx.paramType(paramType);
}
else {
int length = string.length();
// If non 7-bit ASCII characters are present, multiply the length by
// 4 to be sure that even UTF-32 collations will fit. But don't use
// larger numbers than Derby's upper limit 32672
for (int i = 0; i < length; i++) {
if (string.charAt(i) > 127) {
return Math.min(32672, 4 * length);
}
}
return Math.min(32672, length);
}
}
private final void toSQLCast(RenderContext context, DataType<?> type, int length, int precision, int scale) {
context.keyword("cast").sql("(");
toSQL(context, value, getConverter());
context.sql(" ").keyword("as").sql(" ")
.sql(type.length(length).precision(precision, scale).getCastTypeName(context.configuration()))
.sql(")");
}
/**
* Get a bind variable, depending on value of
* {@link RenderContext#namedParams()}
*/
private final String getBindVariable(RenderContext context) {
if (context.paramType() == NAMED || context.paramType() == NAMED_OR_INLINED) {
int index = context.nextIndex();
if (StringUtils.isBlank(getParamName())) {
return ":" + index;
}
else {
return ":" + getName();
// [#1302] Bind value only if it was not explicitly forced to be inlined
if (!isInline(ctx)) {
ctx.bindValue(value, this);
}
}
else {
return "?";
}
}
/**
* Inlining abstraction
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private final void toSQL(RenderContext context, Object val, Converter<?, T> converter) {
SQLDialect family = context.configuration().dialect().family();
// [#650] [#3108] Check first, if we have a converter for the supplied type
Class<?> type = converter.fromType();
val = ((Converter) converter).to(val);
if (isInline(context)) {
// [#2223] Some type-casts in this section may seem unnecessary, e.g.
// ((Boolean) val).toString(). They have been put in place to avoid
// accidental type confusions where type != val.getClass(), and thus
// SQL injection may occur
if (val == null) {
context.keyword("null");
}
else if (type == Boolean.class) {
// [#1153] Some dialects don't support boolean literals TRUE and FALSE
if (asList(FIREBIRD, SQLITE).contains(family)) {
context.sql(((Boolean) val) ? "1" : "0");
}
/* [pro] xx
xxxx xx xxxxxxx xx xxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxx xxxx x xxxxx x xxxxxxx
x
xx [/pro] */
else {
context.keyword(((Boolean) val).toString());
}
}
// [#1154] Binary data cannot always be inlined
else if (type == byte[].class) {
byte[] binary = (byte[]) val;
if (asList().contains(family)) {
context.sql("0x")
.sql(convertBytesToHex(binary));
}
/* [pro] xx
xxxx xx xxxxxxx xx xxxx x
xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx
x
xx [/pro] */
else if (asList(DERBY, H2, HSQLDB, MARIADB, MYSQL, SQLITE).contains(family)) {
context.sql("X'")
.sql(convertBytesToHex(binary))
.sql("'");
}
else if (asList().contains(family)) {
context.keyword("hextoraw('")
.sql(convertBytesToHex(binary))
.sql("')");
}
else if (family == POSTGRES) {
context.sql("E'")
.sql(convertBytesToPostgresOctal(binary))
.keyword("'::bytea");
}
// This default behaviour is used in debug logging for dialects
// that do not support inlining binary data
else {
context.sql("X'")
.sql(convertBytesToHex(binary))
.sql("'");
}
}
// Interval extends Number, so let Interval come first!
else if (Interval.class.isAssignableFrom(type)) {
context.sql("'")
.sql(escape(val, context))
.sql("'");
}
else if (Number.class.isAssignableFrom(type)) {
context.sql(((Number) val).toString());
}
// [#1156] Date/Time data types should be inlined using JDBC
// escape syntax
else if (type == Date.class) {
// The SQLite JDBC driver does not implement the escape syntax
// [#1253] SQL Server and Sybase do not implement date literals
if (asList(SQLITE).contains(family)) {
context.sql("'").sql(escape(val, context)).sql("'");
}
/* [pro] xx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx
x
xxxx xx xxxxxxx xx xxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx xx xxxxxx
x
xx [/pro] */
// [#1253] Derby doesn't support the standard literal
else if (family == DERBY) {
context.keyword("date('").sql(escape(val, context)).sql("')");
}
// [#3648] Circumvent a MySQL bug related to date literals
else if (family == MYSQL) {
context.keyword("{d '").sql(escape(val, context)).sql("'}");
}
// Most dialects implement SQL standard date literals
else {
context.keyword("date '").sql(escape(val, context)).sql("'");
}
}
else if (type == Timestamp.class) {
// The SQLite JDBC driver does not implement the escape syntax
// [#1253] SQL Server and Sybase do not implement timestamp literals
if (asList(SQLITE).contains(family)) {
context.sql("'").sql(escape(val, context)).sql("'");
}
/* [pro] xx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx
x
xxxx xx xxxxxxx xx xxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx xx xxxxxxxxxxx
x
xx [/pro] */
// [#1253] Derby doesn't support the standard literal
else if (family == DERBY) {
context.keyword("timestamp('").sql(escape(val, context)).sql("')");
}
// CUBRID timestamps have no fractional seconds
else if (family == CUBRID) {
context.keyword("datetime '").sql(escape(val, context)).sql("'");
}
// [#3648] Circumvent a MySQL bug related to date literals
else if (family == MYSQL) {
context.keyword("{ts '").sql(escape(val, context)).sql("'}");
}
// Most dialects implement SQL standard timestamp literals
else {
context.keyword("timestamp '").sql(escape(val, context)).sql("'");
}
}
else if (type == Time.class) {
// The SQLite JDBC driver does not implement the escape syntax
// [#1253] SQL Server and Sybase do not implement time literals
if (asList(SQLITE).contains(family)) {
context.sql("'").sql(new SimpleDateFormat("HH:mm:ss").format((Time) val)).sql("'");
}
/* [pro] xx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
x
xxxx xx xxxxxxx xx xxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx xx xxxxxxxxx
x
xx [/pro] */
// [#1253] Derby doesn't support the standard literal
else if (family == DERBY) {
context.keyword("time").sql("('").sql(escape(val, context)).sql("')");
}
// [#3648] Circumvent a MySQL bug related to date literals
else if (family == MYSQL) {
context.keyword("{t '").sql(escape(val, context)).sql("'}");
}
/* [pro] xx
xx xxxxxxx xxxxxx xxxxxxx xxxx xxxx xxxxxxxx
xxxx xx xxxxxxx xx xxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx
x
xx [/pro] */
// Most dialects implement SQL standard time literals
else {
context.keyword("time").sql(" '").sql(escape(val, context)).sql("'");
}
}
else if (type.isArray()) {
String separator = "";
// H2 renders arrays as rows
if (family == H2) {
context.sql("(");
for (Object o : ((Object[]) val)) {
context.sql(separator);
toSQL(context, o, new IdentityConverter(type.getComponentType()));
separator = ", ";
}
context.sql(")");
}
// By default, render HSQLDB / POSTGRES syntax
else {
context.keyword("ARRAY");
context.sql("[");
for (Object o : ((Object[]) val)) {
context.sql(separator);
toSQL(context, o, new IdentityConverter(type.getComponentType()));
separator = ", ";
}
context.sql("]");
// [#3214] Some PostgreSQL array type literals need explicit casting
if (family == POSTGRES && EnumType.class.isAssignableFrom(type.getComponentType())) {
context.sql("::")
.keyword(DefaultDataType.getDataType(family, type).getCastTypeName(context.configuration()));
}
}
}
/* [pro] xx
xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxx
x
xx [/pro] */
else if (EnumType.class.isAssignableFrom(type)) {
String literal = ((EnumType) val).getLiteral();
if (literal == null) {
toSQL(context, val, new IdentityConverter(String.class));
}
else {
toSQL(context, val, new IdentityConverter(String.class));
}
}
else if (UDTRecord.class.isAssignableFrom(type)) {
context.sql("[UDT]");
}
// Known fall-through types:
// - Blob, Clob (both not supported by jOOQ)
// - String
// - UUID
else {
context.sql("'")
.sql(escape(val, context), true)
.sql("'");
}
}
// In Postgres, some additional casting must be done in some cases...
else if (family == SQLDialect.POSTGRES) {
// Postgres needs explicit casting for array types
if (type.isArray() && byte[].class != type) {
context.sql(getBindVariable(context));
context.sql("::");
context.keyword(DefaultDataType.getDataType(family, type).getCastTypeName(context.configuration()));
}
// ... and also for enum types
else if (EnumType.class.isAssignableFrom(type)) {
context.sql(getBindVariable(context));
// [#968] Don't cast "synthetic" enum types (note, val can be null!)
EnumType e = (EnumType) type.getEnumConstants()[0];
Schema schema = e.getSchema();
if (schema != null) {
context.sql("::");
schema = using(context.configuration()).map(schema);
if (schema != null && TRUE.equals(context.configuration().settings().isRenderSchema())) {
context.visit(schema);
context.sql(".");
}
context.visit(name(e.getName()));
}
}
else {
context.sql(getBindVariable(context));
}
}
else {
context.sql(getBindVariable(context));
}
}
/**
* Escape a string literal by replacing <code>'</code> by <code>''</code>, and possibly also backslashes.
*/
private final String escape(Object val, Context<?> context) {
String result = val.toString();
if (needsBackslashEscaping(context.configuration()))
result = result.replace("\\", "\\\\");
return result.replace("'", "''");
}
final void bind0(BindContext context) {
// [#1302] Bind value only if it was not explicitly forced to be inlined
if (!isInline(context)) {
context.bindValue(value, this);
}
}
// ------------------------------------------------------------------------
// XXX: Param API
// ------------------------------------------------------------------------
/**
* Convert a byte array to a hex encoded string.
*
* @param value the byte array
* @return the hex encoded string
*/
private static final String convertBytesToHex(byte[] value) {
return convertBytesToHex(value, value.length);
}
/**
* Convert a byte array to a hex encoded string.
*
* @param value the byte array
* @param len the number of bytes to encode
* @return the hex encoded string
*/
private static final String convertBytesToHex(byte[] value, int len) {
char[] buff = new char[len + len];
char[] hex = HEX;
for (int i = 0; i < len; i++) {
int c = value[i] & 0xff;
buff[i + i] = hex[c >> 4];
buff[i + i + 1] = hex[c & 0xf];
}
return new String(buff);
}
/**
* Postgres uses octals instead of hex encoding
*/
private static final String convertBytesToPostgresOctal(byte[] binary) {
StringBuilder sb = new StringBuilder();
for (byte b : binary) {
sb.append("\\\\");
sb.append(leftPad(toOctalString(b), 3, '0'));
}
return sb.toString();
}
}