[#6933] Add org.jooq.Statement for procedural statements inside of org.jooq.Block
This commit is contained in:
parent
710a452b59
commit
f0cfb14d8e
@ -67,7 +67,6 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -689,20 +688,20 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
Queries queries(Collection<? extends Query> queries);
|
||||
|
||||
/**
|
||||
* Wrap a collection of queries in an anonymous procedural block.
|
||||
* Wrap a collection of statements in an anonymous procedural block.
|
||||
*
|
||||
* @see DSL#begin(Query...)
|
||||
* @see DSL#begin(Statement...)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
Block begin(Query... queries);
|
||||
Block begin(Statement... statements);
|
||||
|
||||
/**
|
||||
* Wrap a collection of queries in an anoymous procedural block.
|
||||
* Wrap a collection of statements in an anoymous procedural block.
|
||||
*
|
||||
* @see DSL#begin(Collection)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
Block begin(Collection<? extends Query> queries);
|
||||
Block begin(Collection<? extends Statement> statements);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Plain SQL API
|
||||
@ -7986,7 +7985,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* s.execute();
|
||||
* </pre></code>
|
||||
*
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batch(Query... queries);
|
||||
@ -8005,7 +8004,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* s.execute();
|
||||
* </pre></code>
|
||||
*
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batch(Queries queries);
|
||||
@ -8019,7 +8018,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #query(String)
|
||||
* @see #batch(Query...)
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batch(String... queries);
|
||||
@ -8038,7 +8037,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* s.execute();
|
||||
* </pre></code>
|
||||
*
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batch(Collection<? extends Query> queries);
|
||||
@ -8072,7 +8071,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* {@link #batch(Query...)}, if you choose to execute queries with
|
||||
* <code>{@link Settings#getStatementType()} == {@link StatementType#STATIC_STATEMENT}</code>
|
||||
*
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
BatchBindStep batch(Query query);
|
||||
@ -8086,7 +8085,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #query(String)
|
||||
* @see #batch(Query)
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
BatchBindStep batch(String sql);
|
||||
@ -8103,7 +8102,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* <code>{@link Settings#getStatementType()} == {@link StatementType#STATIC_STATEMENT}</code>
|
||||
*
|
||||
* @see #batch(Query)
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batch(Query query, Object[]... bindings);
|
||||
@ -8117,7 +8116,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #query(String)
|
||||
* @see #batch(Query, Object[][])
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batch(String sql, Object[]... bindings);
|
||||
@ -8172,7 +8171,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* individual record has been fetched from the database prior to storing it.
|
||||
*
|
||||
* @see UpdatableRecord#store()
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchStore(UpdatableRecord<?>... records);
|
||||
@ -8184,7 +8183,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #batchStore(UpdatableRecord...)
|
||||
* @see UpdatableRecord#store()
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchStore(Collection<? extends UpdatableRecord<?>> records);
|
||||
@ -8196,7 +8195,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #batchStore(UpdatableRecord...)
|
||||
* @see TableRecord#insert()
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchInsert(TableRecord<?>... records);
|
||||
@ -8207,7 +8206,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* {@link TableRecord#insert()} semantics.
|
||||
*
|
||||
* @see #batchStore(UpdatableRecord...)
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchInsert(Collection<? extends TableRecord<?>> records);
|
||||
@ -8219,7 +8218,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #batchStore(UpdatableRecord...)
|
||||
* @see UpdatableRecord#update()
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchUpdate(UpdatableRecord<?>... records);
|
||||
@ -8231,7 +8230,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #batchStore(UpdatableRecord...)
|
||||
* @see UpdatableRecord#update()
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchUpdate(Collection<? extends UpdatableRecord<?>> records);
|
||||
@ -8277,7 +8276,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* only a single batch statement is serialised to the database.
|
||||
*
|
||||
* @see UpdatableRecord#delete()
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchDelete(UpdatableRecord<?>... records);
|
||||
@ -8289,7 +8288,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see #batchDelete(UpdatableRecord...)
|
||||
* @see UpdatableRecord#delete()
|
||||
* @see Statement#executeBatch()
|
||||
* @see java.sql.Statement#executeBatch()
|
||||
*/
|
||||
@Support
|
||||
Batch batchDelete(Collection<? extends UpdatableRecord<?>> records);
|
||||
|
||||
@ -39,7 +39,6 @@
|
||||
package org.jooq;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
@ -57,7 +56,7 @@ import org.jooq.impl.DSL;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Query extends QueryPart, Attachable , AutoCloseable {
|
||||
public interface Query extends Statement, Attachable , AutoCloseable {
|
||||
|
||||
/**
|
||||
* Execute the query, if it has been created with a proper configuration.
|
||||
@ -295,7 +294,7 @@ public interface Query extends QueryPart, Attachable , AutoCloseable {
|
||||
* Specify the query timeout in number of seconds for the underlying JDBC
|
||||
* {@link Statement}.
|
||||
*
|
||||
* @see Statement#setQueryTimeout(int)
|
||||
* @see java.sql.Statement#setQueryTimeout(int)
|
||||
*/
|
||||
Query queryTimeout(int seconds);
|
||||
|
||||
@ -321,7 +320,7 @@ public interface Query extends QueryPart, Attachable , AutoCloseable {
|
||||
* statement, this call is simply ignored.
|
||||
*
|
||||
* @throws DataAccessException If something went wrong closing the statement
|
||||
* @see Statement#close()
|
||||
* @see java.sql.Statement#close()
|
||||
*/
|
||||
|
||||
@Override
|
||||
@ -337,7 +336,7 @@ public interface Query extends QueryPart, Attachable , AutoCloseable {
|
||||
*
|
||||
* @throws DataAccessException If something went wrong cancelling the
|
||||
* statement
|
||||
* @see Statement#cancel()
|
||||
* @see java.sql.Statement#cancel()
|
||||
*/
|
||||
void cancel() throws DataAccessException;
|
||||
|
||||
|
||||
48
jOOQ/src/main/java/org/jooq/Statement.java
Normal file
48
jOOQ/src/main/java/org/jooq/Statement.java
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* A statement that can be placed inside of a {@link Block}, but not executed on
|
||||
* its own.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Statement extends QueryPart {
|
||||
|
||||
}
|
||||
@ -57,8 +57,8 @@ import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DDLQuery;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Statement;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -68,18 +68,18 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 6881305779639901498L;
|
||||
private static final long serialVersionUID = 6881305779639901498L;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final Collection<? extends Query> queries;
|
||||
private final Collection<? extends Statement> statements;
|
||||
|
||||
BlockImpl(Configuration configuration, Collection<? extends Query> queries) {
|
||||
BlockImpl(Configuration configuration, Collection<? extends Statement> statements) {
|
||||
super(configuration);
|
||||
|
||||
this.queries = queries;
|
||||
this.statements = statements;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,7 +117,7 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
ctx.visit(K_BEGIN)
|
||||
.formatIndentStart();
|
||||
|
||||
if (queries.isEmpty()) {
|
||||
if (statements.isEmpty()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Query query : queries) {
|
||||
for (Statement query : statements) {
|
||||
ctx.formatSeparator();
|
||||
|
||||
|
||||
|
||||
@ -290,6 +290,7 @@ import org.jooq.SelectField;
|
||||
import org.jooq.SelectSelectStep;
|
||||
import org.jooq.SelectWhereStep;
|
||||
import org.jooq.Sequence;
|
||||
import org.jooq.Statement;
|
||||
import org.jooq.Support;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableLike;
|
||||
@ -9240,23 +9241,23 @@ public class DSL {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a collection of queries in an anonymous procedural block.
|
||||
* Wrap a collection of statements in an anonymous procedural block.
|
||||
*
|
||||
* @see DSLContext#begin(Query...)
|
||||
* @see DSLContext#begin(Statement...)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static Block begin(Query... queries) {
|
||||
return begin(Arrays.asList(queries));
|
||||
public static Block begin(Statement... statements) {
|
||||
return begin(Arrays.asList(statements));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a collection of queries in an anonymous procedural block.
|
||||
* Wrap a collection of statements in an anonymous procedural block.
|
||||
*
|
||||
* @see DSLContext#begin(Collection)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static Block begin(Collection<? extends Query> queries) {
|
||||
return DSL.using(new DefaultConfiguration()).begin(queries);
|
||||
public static Block begin(Collection<? extends Statement> statements) {
|
||||
return DSL.using(new DefaultConfiguration()).begin(statements);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -223,6 +223,7 @@ import org.jooq.SelectQuery;
|
||||
import org.jooq.SelectSelectStep;
|
||||
import org.jooq.SelectWhereStep;
|
||||
import org.jooq.Sequence;
|
||||
import org.jooq.Statement;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.TableLike;
|
||||
@ -742,13 +743,13 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block begin(Query... queries) {
|
||||
return begin(Arrays.asList(queries));
|
||||
public Block begin(Statement... statements) {
|
||||
return begin(Arrays.asList(statements));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block begin(Collection<? extends Query> queries) {
|
||||
return new BlockImpl(configuration(), queries);
|
||||
public Block begin(Collection<? extends Statement> statements) {
|
||||
return new BlockImpl(configuration(), statements);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user