[#5149] Pull up AttachableInternal.configuration() to Attachable. Remove AttachableInternal
This commit is contained in:
parent
8d37bcb849
commit
58a8aef196
@ -75,4 +75,10 @@ public interface Attachable extends Serializable {
|
||||
* This is the same as calling <code>attach(null)</code>.
|
||||
*/
|
||||
void detach();
|
||||
|
||||
/**
|
||||
* Get the currently attached {@link Configuration}, or <code>null</code> if
|
||||
* no <code>Configuration</code> is attached.
|
||||
*/
|
||||
Configuration configuration();
|
||||
}
|
||||
|
||||
@ -1,52 +0,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.
|
||||
*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Base functionality declaration for all {@link Attachable}s
|
||||
* <p>
|
||||
* This interface is for JOOQ INTERNAL USE only. Do not reference directly
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface AttachableInternal extends Attachable {
|
||||
|
||||
/**
|
||||
* Get the underlying configuration
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
}
|
||||
@ -44,7 +44,7 @@ import org.jooq.exception.DetachedException;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Queries extends QueryPart, Iterable<Query> {
|
||||
public interface Queries extends QueryPart, Attachable, Iterable<Query> {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Access API
|
||||
|
||||
@ -81,7 +81,7 @@ import org.jooq.exception.DataAccessException;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Routine<T> extends QueryPart {
|
||||
public interface Routine<T> extends QueryPart, Attachable {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Meta information
|
||||
|
||||
@ -39,7 +39,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
@ -64,11 +63,7 @@ abstract class AbstractDelegatingQuery<Q extends Query> extends AbstractQueryPar
|
||||
|
||||
@Override
|
||||
public final Configuration configuration() {
|
||||
if (delegate instanceof AttachableInternal) {
|
||||
return ((AttachableInternal) delegate).configuration();
|
||||
}
|
||||
|
||||
return super.configuration();
|
||||
return delegate.configuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -60,7 +60,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
@ -78,7 +77,7 @@ import org.jooq.tools.JooqLogger;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractQuery extends AbstractQueryPart implements Query, AttachableInternal {
|
||||
abstract class AbstractQuery extends AbstractQueryPart implements Query {
|
||||
|
||||
private static final long serialVersionUID = -8046199737354507547L;
|
||||
private static final JooqLogger log = JooqLogger.getLogger(AbstractQuery.class);
|
||||
|
||||
@ -89,7 +89,6 @@ import java.util.Set;
|
||||
|
||||
import org.jooq.AggregateFunction;
|
||||
// ...
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Binding;
|
||||
import org.jooq.Catalog;
|
||||
@ -129,7 +128,7 @@ import org.jooq.tools.reflect.Reflect;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Routine<T>, AttachableInternal {
|
||||
public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Routine<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -39,7 +39,6 @@ import java.util.List;
|
||||
|
||||
// ...
|
||||
import org.jooq.Attachable;
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record;
|
||||
@ -52,7 +51,7 @@ import org.jooq.Record;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractStore implements AttachableInternal {
|
||||
abstract class AbstractStore implements Attachable {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -43,7 +43,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Batch;
|
||||
import org.jooq.BatchBindStep;
|
||||
import org.jooq.Configuration;
|
||||
@ -112,7 +111,7 @@ final class BatchCRUD implements Batch {
|
||||
local.settings().setExecuteLogging(false);
|
||||
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
Configuration previous = ((AttachableInternal) records[i]).configuration();
|
||||
Configuration previous = records[i].configuration();
|
||||
|
||||
try {
|
||||
records[i].attach(local);
|
||||
@ -175,7 +174,7 @@ final class BatchCRUD implements Batch {
|
||||
));
|
||||
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
Configuration previous = ((AttachableInternal) records[i]).configuration();
|
||||
Configuration previous = records[i].configuration();
|
||||
|
||||
try {
|
||||
records[i].attach(local);
|
||||
|
||||
@ -71,7 +71,6 @@ import java.util.stream.Stream;
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.jooq.Attachable;
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Record;
|
||||
@ -886,14 +885,9 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
|
||||
private static <E> E attach(E attachable, Record record) {
|
||||
// [#2869] Attach the mapped outcome if it is Attachable and if the context's
|
||||
// Settings.attachRecords flag is set
|
||||
if (attachable instanceof Attachable && record instanceof AttachableInternal) {
|
||||
Attachable a = (Attachable) attachable;
|
||||
AttachableInternal r = (AttachableInternal) record;
|
||||
|
||||
if (Tools.attachRecords(r.configuration())) {
|
||||
a.attach(r.configuration());
|
||||
}
|
||||
}
|
||||
if (attachable instanceof Attachable)
|
||||
if (Tools.attachRecords(record.configuration()))
|
||||
((Attachable) attachable).attach(record.configuration());
|
||||
|
||||
return attachable;
|
||||
}
|
||||
|
||||
@ -40,7 +40,6 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
@ -54,7 +53,7 @@ import org.jooq.impl.ResultsImpl.ResultOrRowsImpl;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class QueriesImpl extends AbstractQueryPart implements Queries, AttachableInternal {
|
||||
final class QueriesImpl extends AbstractQueryPart implements Queries {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -43,7 +43,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Constraint;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Field;
|
||||
@ -196,12 +195,11 @@ final class ReferenceImpl<R extends Record, O extends Record> extends AbstractKe
|
||||
/**
|
||||
* Extract a configuration from the first record of a collection of records
|
||||
*/
|
||||
private static <R extends Record> DSLContext extractDSLContext(Collection<? extends R> records)
|
||||
throws DetachedException {
|
||||
private static <R extends Record> DSLContext extractDSLContext(Collection<? extends R> records) {
|
||||
R first = first(records);
|
||||
|
||||
if (first instanceof AttachableInternal)
|
||||
return DSL.using(((AttachableInternal) first).configuration());
|
||||
if (first != null)
|
||||
return DSL.using(first.configuration());
|
||||
else
|
||||
throw new DetachedException("Supply at least one attachable record");
|
||||
}
|
||||
|
||||
@ -73,7 +73,6 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.CSVFormat;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Constants;
|
||||
@ -138,7 +137,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
* @author Ivan Dugic
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked" })
|
||||
final class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
final class ResultImpl<R extends Record> implements Result<R> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -38,7 +38,6 @@ import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Result;
|
||||
@ -48,7 +47,7 @@ import org.jooq.Results;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class ResultsImpl extends AbstractList<Result<Record>> implements Results, AttachableInternal {
|
||||
final class ResultsImpl extends AbstractList<Result<Record>> implements Results {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -160,7 +160,6 @@ import javax.persistence.Id;
|
||||
|
||||
// ...
|
||||
import org.jooq.Attachable;
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Catalog;
|
||||
import org.jooq.Clause;
|
||||
@ -673,11 +672,7 @@ final class Tools {
|
||||
* Extract the configuration from an attachable.
|
||||
*/
|
||||
static final Configuration getConfiguration(Attachable attachable) {
|
||||
if (attachable instanceof AttachableInternal) {
|
||||
return ((AttachableInternal) attachable).configuration();
|
||||
}
|
||||
|
||||
return null;
|
||||
return attachable.configuration();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -685,9 +680,7 @@ final class Tools {
|
||||
* if <code>null</code>.
|
||||
*/
|
||||
static final Configuration configuration(Attachable attachable) {
|
||||
return configuration(attachable instanceof AttachableInternal
|
||||
? ((AttachableInternal) attachable).configuration()
|
||||
: null);
|
||||
return configuration(attachable.configuration());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -36,11 +36,9 @@ package org.jooq.tools.jdbc;
|
||||
|
||||
import static org.jooq.impl.DSL.using;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.impl.DefaultConfiguration;
|
||||
|
||||
/**
|
||||
* Various utilities related to {@link MockDataProvider}.
|
||||
@ -90,11 +88,7 @@ public final class Mock {
|
||||
* Wrap a record in a result.
|
||||
*/
|
||||
static final Result<?> result(Record data) {
|
||||
Configuration configuration = data instanceof AttachableInternal
|
||||
? ((AttachableInternal) data).configuration()
|
||||
: new DefaultConfiguration();
|
||||
|
||||
Result<Record> result = using(configuration).newResult(data.fields());
|
||||
Result<Record> result = using(data.configuration()).newResult(data.fields());
|
||||
result.add(data);
|
||||
|
||||
return result;
|
||||
|
||||
@ -38,7 +38,6 @@ import java.io.Serializable;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Schema;
|
||||
@ -164,19 +163,16 @@ public class MockResultSetMetaData implements ResultSetMetaData, Serializable {
|
||||
Schema schema = table.getSchema();
|
||||
|
||||
if (schema != null) {
|
||||
Configuration configuration = ((AttachableInternal) rs.result).configuration();
|
||||
Configuration configuration = rs.result.configuration();
|
||||
Schema mapped = null;
|
||||
|
||||
if (configuration != null) {
|
||||
if (configuration != null)
|
||||
mapped = DSL.using(configuration).map(schema);
|
||||
}
|
||||
|
||||
if (mapped != null) {
|
||||
if (mapped != null)
|
||||
return mapped.getName();
|
||||
}
|
||||
else {
|
||||
else
|
||||
return schema.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user