mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2313 - Refactor internals - make more classes final in query packages
This commit is contained in:
@@ -26,22 +26,22 @@ abstract class BaseFuture<T> implements Future<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get() throws InterruptedException, ExecutionException {
|
||||
public final T get() throws InterruptedException, ExecutionException {
|
||||
return futureTask.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
public final T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return futureTask.get(timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
public final boolean isCancelled() {
|
||||
return futureTask.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
public final boolean isDone() {
|
||||
return futureTask.isDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* The tree structure is flattened into a SqlSelectChain. The SqlSelectChain is
|
||||
* the key object used in reading the flat resultSet back into Objects.
|
||||
*/
|
||||
public class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfileTransactionEvent {
|
||||
public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfileTransactionEvent {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CQuery.class);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
class CQueryBindCapture implements SpiQueryBindCapture {
|
||||
final class CQueryBindCapture implements SpiQueryBindCapture {
|
||||
|
||||
private static final double multiplier = 1.5d;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.util.List;
|
||||
* Generates the SQL SELECT statements taking into account the physical
|
||||
* deployment properties.
|
||||
*/
|
||||
class CQueryBuilder {
|
||||
final class CQueryBuilder {
|
||||
|
||||
private final String columnAliasPrefix;
|
||||
private final SqlLimiter sqlLimiter;
|
||||
|
||||
@@ -11,7 +11,7 @@ import io.ebeaninternal.server.querydefn.OrmQueryLimitRequest;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
import io.ebeaninternal.server.util.BindParamsParser;
|
||||
|
||||
class CQueryBuilderRawSql {
|
||||
final class CQueryBuilderRawSql {
|
||||
|
||||
private final SqlLimiter sqlLimiter;
|
||||
private final DatabasePlatform dbPlatform;
|
||||
|
||||
@@ -7,7 +7,7 @@ import io.ebean.bean.EntityBean;
|
||||
* A NOOP based CQueryCollectionAdd for use with lazy loading many queries where the
|
||||
* beans loaded into the collection are added to the collection(s) of the parent(s).
|
||||
*/
|
||||
class CQueryCollectionAddNoop<T> implements CQueryCollectionAdd<T> {
|
||||
final class CQueryCollectionAddNoop<T> implements CQueryCollectionAdd<T> {
|
||||
|
||||
/**
|
||||
* Return null as we are not collecting the beans.
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Support 'asDraft' queries.
|
||||
*/
|
||||
class CQueryDraftSupport {
|
||||
final class CQueryDraftSupport {
|
||||
|
||||
/**
|
||||
* The mapping of base tables to their matching 'draft' table.
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Handles the Object Relational fetching.
|
||||
*/
|
||||
public class CQueryEngine {
|
||||
public final class CQueryEngine {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CQueryEngine.class);
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
/**
|
||||
* Base compiled query request for single attribute queries.
|
||||
*/
|
||||
class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, CancelableQuery {
|
||||
final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, CancelableQuery {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CQueryFetchSingleAttribute.class);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Helper to support history functions.
|
||||
*/
|
||||
class CQueryHistorySupport {
|
||||
final class CQueryHistorySupport {
|
||||
|
||||
/**
|
||||
* The DB specific support.
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.sql.SQLException;
|
||||
/**
|
||||
* QueryIterator that does not require a buffer for secondary queries.
|
||||
*/
|
||||
class CQueryIteratorSimple<T> implements QueryIterator<T> {
|
||||
final class CQueryIteratorSimple<T> implements QueryIterator<T> {
|
||||
|
||||
private final CQuery<T> cquery;
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.util.NoSuchElementException;
|
||||
/**
|
||||
* A QueryIterator that uses a buffer to execute secondary queries periodically.
|
||||
*/
|
||||
class CQueryIteratorWithBuffer<T> implements QueryIterator<T> {
|
||||
final class CQueryIteratorWithBuffer<T> implements QueryIterator<T> {
|
||||
|
||||
private final CQuery<T> cquery;
|
||||
private final int bufferSize;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
/**
|
||||
* Creates the order by expression clause.
|
||||
*/
|
||||
class CQueryOrderBy {
|
||||
final class CQueryOrderBy {
|
||||
|
||||
private final BeanDescriptor<?> desc;
|
||||
|
||||
|
||||
@@ -164,49 +164,49 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getBeanType() {
|
||||
public final Class<?> getBeanType() {
|
||||
return beanType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash() {
|
||||
public final String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSql() {
|
||||
public final String getSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileLocation getProfileLocation() {
|
||||
public final ProfileLocation getProfileLocation() {
|
||||
return profileLocation;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
public final String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public Set<String> getDependentTables() {
|
||||
public final Set<String> getDependentTables() {
|
||||
return dependentTables;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
public final String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryPlanInit(long thresholdMicros) {
|
||||
public final void queryPlanInit(long thresholdMicros) {
|
||||
bindCapture.queryPlanInit(thresholdMicros);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DQueryPlanOutput createMeta(String bind, String planString) {
|
||||
public final DQueryPlanOutput createMeta(String bind, String planString) {
|
||||
return new DQueryPlanOutput(getBeanType(), name, hash, sql, profileLocation, bind, planString);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
/**
|
||||
* Bind keys for encrypted properties if necessary returning the DataBind.
|
||||
*/
|
||||
DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException {
|
||||
final DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException {
|
||||
DataBind dataBind = new DataBind(dataTimeZone, stmt, conn);
|
||||
if (encryptedProps != null) {
|
||||
for (STreeProperty encryptedProp : encryptedProps) {
|
||||
@@ -237,14 +237,14 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
return dataBind;
|
||||
}
|
||||
|
||||
int getAsOfTableCount() {
|
||||
final int getAsOfTableCount() {
|
||||
return asOfTableCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a key used in audit logging to identify the query.
|
||||
*/
|
||||
String getAuditQueryKey() {
|
||||
final String getAuditQueryKey() {
|
||||
if (auditQueryHash == null) {
|
||||
// volatile object assignment (so happy for multithreaded access)
|
||||
auditQueryHash = calcAuditQueryKey();
|
||||
@@ -257,29 +257,29 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
return rawSql ? planKey.getPartialKey() + "_" + hash : planKey.getPartialKey();
|
||||
}
|
||||
|
||||
SqlTree getSqlTree() {
|
||||
final SqlTree getSqlTree() {
|
||||
return sqlTree;
|
||||
}
|
||||
|
||||
public boolean isRawSql() {
|
||||
public final boolean isRawSql() {
|
||||
return rawSql;
|
||||
}
|
||||
|
||||
String getLogWhereSql() {
|
||||
final String getLogWhereSql() {
|
||||
return logWhereSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the query statistics.
|
||||
*/
|
||||
public void resetStatistics() {
|
||||
public final void resetStatistics() {
|
||||
stats.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an execution time against this query plan;
|
||||
*/
|
||||
boolean executionTime(long timeMicros) {
|
||||
final boolean executionTime(long timeMicros) {
|
||||
stats.add(timeMicros);
|
||||
return bindCapture != null && bindCapture.collectFor(timeMicros);
|
||||
}
|
||||
@@ -287,33 +287,33 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
/**
|
||||
* Return a copy of the current query statistics.
|
||||
*/
|
||||
public Snapshot getSnapshot(boolean reset) {
|
||||
public final Snapshot getSnapshot(boolean reset) {
|
||||
return stats.getSnapshot(reset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time this query plan was last used.
|
||||
*/
|
||||
public long getLastQueryTime() {
|
||||
public final long getLastQueryTime() {
|
||||
return stats.getLastQueryTime();
|
||||
}
|
||||
|
||||
ScalarDataReader<?> getSingleAttributeScalarType() {
|
||||
final ScalarDataReader<?> getSingleAttributeScalarType() {
|
||||
return sqlTree.getRootNode().getSingleAttributeReader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there are no statistics collected since the last reset.
|
||||
*/
|
||||
public boolean isEmptyStats() {
|
||||
public final boolean isEmptyStats() {
|
||||
return stats.isEmpty();
|
||||
}
|
||||
|
||||
TimedMetric createTimedMetric() {
|
||||
final TimedMetric createTimedMetric() {
|
||||
return MetricFactory.get().createTimedMetric(label);
|
||||
}
|
||||
|
||||
void captureBindForQueryPlan(CQueryPredicates predicates, long executionTimeMicros) {
|
||||
final void captureBindForQueryPlan(CQueryPredicates predicates, long executionTimeMicros) {
|
||||
final long startNanos = System.nanoTime();
|
||||
try {
|
||||
DataBindCapture capture = bindCapture();
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
public class CQueryPlanManager implements QueryPlanManager {
|
||||
public final class CQueryPlanManager implements QueryPlanManager {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CQueryPlanManager.class);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
/**
|
||||
* RawSql based query plan.
|
||||
*/
|
||||
class CQueryPlanRawSql extends CQueryPlan {
|
||||
final class CQueryPlanRawSql extends CQueryPlan {
|
||||
|
||||
private final int[] rsetIndexPositions;
|
||||
|
||||
@@ -27,7 +27,6 @@ class CQueryPlanRawSql extends CQueryPlan {
|
||||
}
|
||||
|
||||
private int[] createIndexPositions(OrmQueryRequest<?> request, SqlTree sqlTree) {
|
||||
|
||||
List<String> chain = sqlTree.buildRawSqlSelectChain();
|
||||
ColumnMapping columnMapping = request.getQuery().getRawSql().getColumnMapping();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
/**
|
||||
* Captures database query plans.
|
||||
*/
|
||||
class CQueryPlanRequest {
|
||||
final class CQueryPlanRequest {
|
||||
|
||||
private final List<MetaQueryPlan> plans = new ArrayList<>();
|
||||
|
||||
@@ -19,7 +19,7 @@ class CQueryPlanRequest {
|
||||
private final long since;
|
||||
private final int maxCount;
|
||||
private final long maxTime;
|
||||
private Iterator<CQueryBindCapture> iterator;
|
||||
private final Iterator<CQueryBindCapture> iterator;
|
||||
|
||||
CQueryPlanRequest(Connection connection, QueryPlanRequest req, Iterator<CQueryBindCapture> iterator) {
|
||||
this.connection = connection;
|
||||
|
||||
@@ -10,11 +10,8 @@ import io.ebean.metric.TimedMetricStats;
|
||||
public final class CQueryPlanStats {
|
||||
|
||||
private final CQueryPlan queryPlan;
|
||||
|
||||
private final TimedMetric timedMetric;
|
||||
|
||||
private boolean collected;
|
||||
|
||||
private long lastQueryTime;
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,74 +37,51 @@ import java.util.Set;
|
||||
* named parameters and expression values into the prepared statement.
|
||||
* </p>
|
||||
*/
|
||||
public class CQueryPredicates {
|
||||
public final class CQueryPredicates {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CQueryPredicates.class);
|
||||
|
||||
private final Binder binder;
|
||||
|
||||
private final OrmQueryRequest<?> request;
|
||||
|
||||
private final SpiQuery<?> query;
|
||||
|
||||
private final Object idValue;
|
||||
|
||||
/**
|
||||
* Named bind parameters.
|
||||
*/
|
||||
private final BindParams bindParams;
|
||||
|
||||
/**
|
||||
* Bind values from the where expressions.
|
||||
*/
|
||||
private DefaultExpressionRequest filterMany;
|
||||
|
||||
/**
|
||||
* SQL generated from the where expressions.
|
||||
*/
|
||||
private String filterManyExprSql;
|
||||
|
||||
/**
|
||||
* Bind values from the where expressions.
|
||||
*/
|
||||
private DefaultExpressionRequest where;
|
||||
|
||||
/**
|
||||
* SQL generated from the where expressions.
|
||||
*/
|
||||
private String whereExprSql;
|
||||
|
||||
/**
|
||||
* Bind values for having expression.
|
||||
*/
|
||||
private DefaultExpressionRequest having;
|
||||
|
||||
/**
|
||||
* SQL generated from the having expression.
|
||||
*/
|
||||
private String havingExprSql;
|
||||
|
||||
private String dbHaving;
|
||||
|
||||
/**
|
||||
* logicalWhere with property names converted to db columns.
|
||||
*/
|
||||
private String dbWhere;
|
||||
|
||||
/**
|
||||
* Filter than can apply to a many fetch join.
|
||||
*/
|
||||
private String dbFilterMany;
|
||||
|
||||
private String dbOrderBy;
|
||||
|
||||
private String dbUpdateClause;
|
||||
|
||||
/**
|
||||
* Includes from where and order by clauses.
|
||||
*/
|
||||
private Set<String> predicateIncludes;
|
||||
|
||||
private Set<String> orderByIncludes;
|
||||
|
||||
CQueryPredicates(Binder binder, OrmQueryRequest<?> request) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
/**
|
||||
* Executes the select row count query.
|
||||
*/
|
||||
class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuery {
|
||||
final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuery {
|
||||
|
||||
private final CQueryPlan queryPlan;
|
||||
private final OrmQueryRequest<?> request;
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
/**
|
||||
* Executes the update query.
|
||||
*/
|
||||
class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery {
|
||||
final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery {
|
||||
|
||||
private final CQueryPlan queryPlan;
|
||||
private final OrmQueryRequest<?> request;
|
||||
|
||||
@@ -10,9 +10,7 @@ import io.ebeaninternal.api.SpiQuery;
|
||||
abstract class CallableQuery<T> {
|
||||
|
||||
final SpiQuery<T> query;
|
||||
|
||||
final SpiEbeanServer server;
|
||||
|
||||
final Transaction transaction;
|
||||
|
||||
CallableQuery(SpiEbeanServer server, SpiQuery<T> query, Transaction t) {
|
||||
|
||||
@@ -8,10 +8,8 @@ import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Represent the findCount query as a Callable.
|
||||
*
|
||||
* @param <T> the entity bean type
|
||||
*/
|
||||
public class CallableQueryCount<T> extends CallableQuery<T> implements Callable<Integer> {
|
||||
public final class CallableQueryCount<T> extends CallableQuery<T> implements Callable<Integer> {
|
||||
|
||||
/**
|
||||
* Note that the transaction passed in is always a new transaction solely to
|
||||
|
||||
@@ -9,10 +9,8 @@ import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Represent the fetch Id's query as a Callable.
|
||||
*
|
||||
* @param <T> the entity bean type
|
||||
*/
|
||||
public class CallableQueryIds<T> extends CallableQuery<T> implements Callable<List<Object>> {
|
||||
public final class CallableQueryIds<T> extends CallableQuery<T> implements Callable<List<Object>> {
|
||||
|
||||
|
||||
public CallableQueryIds(SpiEbeanServer server, SpiQuery<T> query, Transaction t) {
|
||||
|
||||
@@ -12,8 +12,7 @@ import java.util.concurrent.Callable;
|
||||
*
|
||||
* @param <T> the entity bean type
|
||||
*/
|
||||
public class CallableQueryList<T> extends CallableQuery<T> implements Callable<List<T>> {
|
||||
|
||||
public final class CallableQueryList<T> extends CallableQuery<T> implements Callable<List<T>> {
|
||||
|
||||
public CallableQueryList(SpiEbeanServer server, SpiQuery<T> query, Transaction t) {
|
||||
super(server, query, t);
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.querydefn.SpiFetchGroup;
|
||||
/**
|
||||
* Default FetchGroup implementation.
|
||||
*/
|
||||
class DFetchGroup<T> implements SpiFetchGroup<T> {
|
||||
final class DFetchGroup<T> implements SpiFetchGroup<T> {
|
||||
|
||||
private final OrmQueryDetail detail;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.querydefn.SpiFetchGroup;
|
||||
/**
|
||||
* Default implementation of the FetchGroupBuilder.
|
||||
*/
|
||||
class DFetchGroupBuilder<T> implements FetchGroupBuilder<T> {
|
||||
final class DFetchGroupBuilder<T> implements FetchGroupBuilder<T> {
|
||||
|
||||
private static final FetchConfig DEFAULT_FETCH = FetchConfig.ofDefault();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import io.ebeaninternal.api.SpiDbQueryPlan;
|
||||
/**
|
||||
* Captured query plan details.
|
||||
*/
|
||||
class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
final class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
|
||||
private final Class<?> beanType;
|
||||
private final String label;
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.ebeaninternal.server.query;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class DbOrderByTrim {
|
||||
final class DbOrderByTrim {
|
||||
|
||||
private static final Pattern orderByTrim = Pattern.compile("(?i) asc\\b| desc\\b|\\b nulls first\\b|\\b nulls last\\b");
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.ebeaninternal.server.util.ArrayStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
class DefaultDbSqlContext implements DbSqlContext {
|
||||
final class DefaultDbSqlContext implements DbSqlContext {
|
||||
|
||||
private static final String COMMA = ", ";
|
||||
private static final String PERIOD = ".";
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.util.stream.Stream;
|
||||
/**
|
||||
* Implementation of FetchGroup query for use to create FetchGroup via query beans.
|
||||
*/
|
||||
class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQueryFetch {
|
||||
final class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQueryFetch {
|
||||
|
||||
private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
/**
|
||||
* Main Finder implementation.
|
||||
*/
|
||||
public class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
public final class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
|
||||
/**
|
||||
* Find using predicates
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import java.util.function.Predicate;
|
||||
/**
|
||||
* Perform native sql fetches.
|
||||
*/
|
||||
public class DefaultRelationalQueryEngine implements RelationalQueryEngine {
|
||||
public final class DefaultRelationalQueryEngine implements RelationalQueryEngine {
|
||||
|
||||
private final Binder binder;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.UUID;
|
||||
* returning the type you expect.
|
||||
* </p>
|
||||
*/
|
||||
public class DefaultSqlRow implements SqlRow {
|
||||
public final class DefaultSqlRow implements SqlRow {
|
||||
|
||||
private static final long serialVersionUID = -3120927797041336242L;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class DtoQueryEngine {
|
||||
public final class DtoQueryEngine {
|
||||
|
||||
private final Binder binder;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.core.DtoQueryRequest;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
class DtoQueryIterator<T> implements QueryIterator<T> {
|
||||
final class DtoQueryIterator<T> implements QueryIterator<T> {
|
||||
|
||||
private final DtoQueryRequest<T> request;
|
||||
private boolean closed;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.query;
|
||||
|
||||
public class ExtraJoin {
|
||||
public final class ExtraJoin {
|
||||
|
||||
private final STreePropertyAssoc property;
|
||||
private final boolean containsMany;
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
/**
|
||||
* PagedList implementation based on limit offset types of queries.
|
||||
*/
|
||||
public class LimitOffsetPagedList<T> implements PagedList<T> {
|
||||
public final class LimitOffsetPagedList<T> implements PagedList<T> {
|
||||
|
||||
private final transient SpiEbeanServer server;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Comparator;
|
||||
/**
|
||||
* Compare Version beans in descending order with nulls last.
|
||||
*/
|
||||
class OrderVersionDesc implements Comparator<Version<?>>, Serializable {
|
||||
final class OrderVersionDesc implements Comparator<Version<?>>, Serializable {
|
||||
|
||||
static final OrderVersionDesc INSTANCE = new OrderVersionDesc();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.concurrent.FutureTask;
|
||||
/**
|
||||
* Default implementation of FutureIds.
|
||||
*/
|
||||
public class QueryFutureIds<T> extends BaseFuture<List<Object>> implements FutureIds<T> {
|
||||
public final class QueryFutureIds<T> extends BaseFuture<List<Object>> implements FutureIds<T> {
|
||||
|
||||
private final CallableQueryIds<T> call;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.concurrent.TimeoutException;
|
||||
/**
|
||||
* Default implementation for FutureList.
|
||||
*/
|
||||
public class QueryFutureList<T> extends BaseFuture<List<T>> implements FutureList<T> {
|
||||
public final class QueryFutureList<T> extends BaseFuture<List<T>> implements FutureList<T> {
|
||||
|
||||
private final CallableQueryList<T> call;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.concurrent.FutureTask;
|
||||
/**
|
||||
* Future implementation for the row count query.
|
||||
*/
|
||||
public class QueryFutureRowCount<T> extends BaseFuture<Integer> implements FutureRowCount<T> {
|
||||
public final class QueryFutureRowCount<T> extends BaseFuture<Integer> implements FutureRowCount<T> {
|
||||
|
||||
private final CallableQueryCount<T> call;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public abstract class QueryPlanLogger {
|
||||
|
||||
abstract SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind);
|
||||
|
||||
SpiDbQueryPlan readQueryPlan(SpiQueryPlan plan, BindCapture bind, ResultSet rset) throws SQLException {
|
||||
final SpiDbQueryPlan readQueryPlan(SpiQueryPlan plan, BindCapture bind, ResultSet rset) throws SQLException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; i <= rset.getMetaData().getColumnCount(); i++) {
|
||||
sb.append(rset.getMetaData().getColumnLabel(i)).append("\t");
|
||||
@@ -27,11 +27,11 @@ public abstract class QueryPlanLogger {
|
||||
return createPlan(plan, bind.toString(), sb.toString());
|
||||
}
|
||||
|
||||
SpiDbQueryPlan createPlan(SpiQueryPlan plan, String bind, String planString) {
|
||||
final SpiDbQueryPlan createPlan(SpiQueryPlan plan, String bind, String planString) {
|
||||
return plan.createMeta(bind, planString);
|
||||
}
|
||||
|
||||
SpiDbQueryPlan readQueryPlanBasic(SpiQueryPlan plan, BindCapture bind, ResultSet rset) throws SQLException {
|
||||
final SpiDbQueryPlan readQueryPlanBasic(SpiQueryPlan plan, BindCapture bind, ResultSet rset) throws SQLException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
readPlanData(sb, rset);
|
||||
return createPlan(plan, bind.toString(), sb.toString().trim());
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.sql.SQLException;
|
||||
/**
|
||||
* A QueryPlanLogger that prefixes "EXPLAIN " to the query. This works for Postgres, H2 and MySql.
|
||||
*/
|
||||
public class QueryPlanLoggerExplain extends QueryPlanLogger {
|
||||
public final class QueryPlanLoggerExplain extends QueryPlanLogger {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.sql.Statement;
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
public class QueryPlanLoggerOracle extends QueryPlanLogger {
|
||||
public final class QueryPlanLoggerOracle extends QueryPlanLogger {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.sql.SQLException;
|
||||
/**
|
||||
* A QueryPlanLogger for Postgres that prefixes "EXPLAIN ANALYZE" to the query.
|
||||
*/
|
||||
public class QueryPlanLoggerPostgres extends QueryPlanLogger {
|
||||
public final class QueryPlanLoggerPostgres extends QueryPlanLogger {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind) {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import java.sql.Statement;
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
public class QueryPlanLoggerSqlServer extends QueryPlanLogger {
|
||||
public final class QueryPlanLoggerSqlServer extends QueryPlanLogger {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* QueryPlanKey for RawSql queries.
|
||||
*/
|
||||
class RawSqlQueryPlanKey implements CQueryPlanKey {
|
||||
final class RawSqlQueryPlanKey implements CQueryPlanKey {
|
||||
|
||||
private final String sql;
|
||||
private final boolean rawSql;
|
||||
|
||||
@@ -13,7 +13,7 @@ import io.ebeaninternal.server.deploy.DbReadContext;
|
||||
* partial objects.
|
||||
* </p>
|
||||
*/
|
||||
public class SqlBeanLoad {
|
||||
public final class SqlBeanLoad {
|
||||
|
||||
private final DbReadContext ctx;
|
||||
private final EntityBean bean;
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Represents the SELECT clause part of the SQL query.
|
||||
*/
|
||||
class SqlTree {
|
||||
final class SqlTree {
|
||||
|
||||
private final SqlTreeNode rootNode;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.TreeSet;
|
||||
/**
|
||||
* Special Map of the logical property joins to table alias.
|
||||
*/
|
||||
class SqlTreeAlias {
|
||||
final class SqlTreeAlias {
|
||||
|
||||
private final SpiQuery.TemporalMode temporalMode;
|
||||
|
||||
|
||||
@@ -30,44 +30,28 @@ public final class SqlTreeBuilder {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SqlTreeBuilder.class);
|
||||
|
||||
private final SpiQuery<?> query;
|
||||
|
||||
private final STreeType desc;
|
||||
|
||||
private final OrmQueryDetail queryDetail;
|
||||
|
||||
private final CQueryPredicates predicates;
|
||||
|
||||
private final boolean subQuery;
|
||||
|
||||
private final boolean distinctOnPlatform;
|
||||
/**
|
||||
* Property if resultSet contains master and detail rows.
|
||||
*/
|
||||
private STreePropertyAssocMany manyProperty;
|
||||
|
||||
private final SqlTreeAlias alias;
|
||||
|
||||
private final DefaultDbSqlContext ctx;
|
||||
|
||||
private final HashSet<String> selectIncludes = new HashSet<>();
|
||||
|
||||
private final ManyWhereJoins manyWhereJoins;
|
||||
|
||||
private final TableJoin includeJoin;
|
||||
|
||||
private final boolean rawSql;
|
||||
|
||||
/**
|
||||
* rawNoId true if the RawSql does not include the @Id property
|
||||
*/
|
||||
private final boolean rawNoId;
|
||||
|
||||
private final boolean disableLazyLoad;
|
||||
|
||||
private final SpiQuery.TemporalMode temporalMode;
|
||||
|
||||
private SqlTreeNode rootNode;
|
||||
|
||||
private boolean sqlDistinct;
|
||||
|
||||
/**
|
||||
@@ -103,9 +87,9 @@ public final class SqlTreeBuilder {
|
||||
this.temporalMode = SpiQuery.TemporalMode.of(query);
|
||||
this.disableLazyLoad = query.isDisableLazyLoading();
|
||||
this.subQuery = Type.SQ_EXISTS == query.getType()
|
||||
|| Type.SQ_IN == query.getType()
|
||||
|| Type.ID_LIST == query.getType()
|
||||
|| Type.DELETE == query.getType()
|
||||
|| Type.SQ_IN == query.getType()
|
||||
|| Type.ID_LIST == query.getType()
|
||||
|| Type.DELETE == query.getType()
|
||||
|| query.isCountDistinct();
|
||||
this.includeJoin = query.getM2mIncludeJoin();
|
||||
this.manyWhereJoins = query.getManyWhereJoins();
|
||||
|
||||
@@ -28,58 +28,40 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
private static final SqlTreeNode[] NO_CHILDREN = new SqlTreeNode[0];
|
||||
|
||||
final STreeType desc;
|
||||
|
||||
final IdBinder idBinder;
|
||||
|
||||
/**
|
||||
* The children which will be other SelectBean or SelectProxyBean.
|
||||
*/
|
||||
final SqlTreeNode[] children;
|
||||
|
||||
/**
|
||||
* Set to true if this is a partial object fetch.
|
||||
*/
|
||||
private final boolean partialObject;
|
||||
|
||||
private final STreeProperty[] properties;
|
||||
|
||||
/**
|
||||
* Extra where clause added by Where annotation on associated many.
|
||||
*/
|
||||
private final String extraWhere;
|
||||
|
||||
private final STreePropertyAssoc nodeBeanProp;
|
||||
|
||||
/**
|
||||
* False if report bean and has no id property.
|
||||
*/
|
||||
final boolean readId;
|
||||
private final boolean readIdNormal;
|
||||
|
||||
private final boolean disableLazyLoad;
|
||||
|
||||
private final InheritInfo inheritInfo;
|
||||
|
||||
final String prefix;
|
||||
|
||||
private final Map<String, String> pathMap;
|
||||
|
||||
final STreePropertyAssocMany lazyLoadParent;
|
||||
|
||||
private final SpiQuery.TemporalMode temporalMode;
|
||||
|
||||
private final boolean temporalVersions;
|
||||
|
||||
private final IdBinder lazyLoadParentIdBinder;
|
||||
|
||||
String baseTableAlias;
|
||||
|
||||
/**
|
||||
* Table alias set if this bean node includes a join to a intersection
|
||||
* table and that table has history support.
|
||||
*/
|
||||
private boolean intersectionAsOfTableAlias;
|
||||
|
||||
private final boolean aggregation;
|
||||
|
||||
/**
|
||||
@@ -131,12 +113,12 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleProperty() {
|
||||
public final boolean isSingleProperty() {
|
||||
return properties != null && properties.length == 1 && children.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalarDataReader<?> getSingleAttributeReader() {
|
||||
public final ScalarDataReader<?> getSingleAttributeReader() {
|
||||
if (properties == null || properties.length == 0) {
|
||||
// if we have no property ask first children (in a distinct select with join)
|
||||
if (children.length == 0) {
|
||||
@@ -172,7 +154,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildRawSqlSelectChain(List<String> selectChain) {
|
||||
public final void buildRawSqlSelectChain(List<String> selectChain) {
|
||||
if (readId) {
|
||||
if (inheritInfo != null) {
|
||||
// discriminator column always proceeds id column
|
||||
@@ -194,7 +176,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
/**
|
||||
* Load that takes into account inheritance.
|
||||
*/
|
||||
private class LoadInherit extends Load {
|
||||
private final class LoadInherit extends Load {
|
||||
|
||||
private LoadInherit(DbReadContext ctx, EntityBean parentBean) {
|
||||
super(ctx, parentBean);
|
||||
@@ -437,7 +419,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
/**
|
||||
* Perform the load returning the loaded bean.
|
||||
*/
|
||||
EntityBean perform() throws SQLException {
|
||||
final EntityBean perform() throws SQLException {
|
||||
initialise();
|
||||
if (isLazyLoadManyRoot()) {
|
||||
return getContextBean();
|
||||
@@ -451,7 +433,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
* Return true if this bean was already in the context. If already in the
|
||||
* context we need to check if it is already contained in the collection.
|
||||
*/
|
||||
boolean isContextBean() {
|
||||
final boolean isContextBean() {
|
||||
return localBean == null;
|
||||
}
|
||||
}
|
||||
@@ -467,12 +449,12 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
/**
|
||||
* Create the loader with or without inheritance.
|
||||
*/
|
||||
Load createLoad(DbReadContext ctx, EntityBean parentBean) {
|
||||
final Load createLoad(DbReadContext ctx, EntityBean parentBean) {
|
||||
return (inheritInfo != null) ? new LoadInherit(ctx, parentBean) : new Load(ctx, parentBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendGroupBy(DbSqlContext ctx, boolean subQuery) {
|
||||
public final void appendGroupBy(DbSqlContext ctx, boolean subQuery) {
|
||||
ctx.pushJoin(prefix);
|
||||
ctx.pushTableAlias(prefix);
|
||||
if (lazyLoadParent != null) {
|
||||
@@ -507,7 +489,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
* Append the property columns to the buffer.
|
||||
*/
|
||||
@Override
|
||||
public void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
public final void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
ctx.pushJoin(prefix);
|
||||
ctx.pushTableAlias(prefix);
|
||||
if (temporalVersions) {
|
||||
@@ -532,7 +514,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAggregation() {
|
||||
public final boolean isAggregation() {
|
||||
if (aggregation) {
|
||||
return true;
|
||||
}
|
||||
@@ -553,14 +535,14 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
}
|
||||
|
||||
void appendSelectId(DbSqlContext ctx, STreeProperty prop) {
|
||||
final void appendSelectId(DbSqlContext ctx, STreeProperty prop) {
|
||||
if (prop != null) {
|
||||
prop.appendSelect(ctx, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendWhere(DbSqlContext ctx) {
|
||||
public final void appendWhere(DbSqlContext ctx) {
|
||||
// Only apply inheritance to root node as any join will already have the inheritance join include - see TableJoin
|
||||
if (inheritInfo != null && nodeBeanProp == null) {
|
||||
if (!inheritInfo.isRoot()) {
|
||||
@@ -618,7 +600,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoftDeletePredicate(SpiQuery<?> query) {
|
||||
public final void addSoftDeletePredicate(SpiQuery<?> query) {
|
||||
if (desc.isSoftDelete()) {
|
||||
query.addSoftDeletePredicate(desc.getSoftDeletePredicate(baseTableAlias));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.query;
|
||||
|
||||
import io.ebean.Version;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebean.util.SplitName;
|
||||
@@ -22,7 +21,7 @@ import java.util.Set;
|
||||
* etc in this case we must add an extra join.
|
||||
* </p>
|
||||
*/
|
||||
class SqlTreeNodeExtraJoin implements SqlTreeNode {
|
||||
final class SqlTreeNodeExtraJoin implements SqlTreeNode {
|
||||
|
||||
private final STreePropertyAssoc assocBeanProperty;
|
||||
private final SpiQuery.TemporalMode temporalMode;
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.query;
|
||||
|
||||
import io.ebean.Version;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
@@ -13,7 +12,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Join to Many (or child of a many) to support where clause predicates on many properties.
|
||||
*/
|
||||
class SqlTreeNodeFormulaWhereJoin implements SqlTreeNode {
|
||||
final class SqlTreeNodeFormulaWhereJoin implements SqlTreeNode {
|
||||
|
||||
private final STreeProperty nodeBeanProp;
|
||||
|
||||
|
||||
+1
-7
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.query;
|
||||
|
||||
import io.ebean.Version;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebean.util.SplitName;
|
||||
@@ -15,21 +14,16 @@ import java.util.Set;
|
||||
/**
|
||||
* Join to Many (or child of a many) to support where clause predicates on many properties.
|
||||
*/
|
||||
class SqlTreeNodeManyWhereJoin implements SqlTreeNode {
|
||||
final class SqlTreeNodeManyWhereJoin implements SqlTreeNode {
|
||||
|
||||
private final String parentPrefix;
|
||||
|
||||
private final String prefix;
|
||||
|
||||
private final STreePropertyAssoc nodeBeanProp;
|
||||
|
||||
private final STreeType target;
|
||||
|
||||
/**
|
||||
* The many where join which is either INNER or OUTER.
|
||||
*/
|
||||
private final SqlJoinType manyJoinType;
|
||||
|
||||
private final boolean softDelete;
|
||||
|
||||
SqlTreeNodeManyWhereJoin(String prefix, STreePropertyAssoc prop, SqlJoinType manyJoinType, SpiQuery.TemporalMode temporalMode) {
|
||||
|
||||
@@ -18,9 +18,7 @@ import java.util.Set;
|
||||
final class SqlTreeNodeRoot extends SqlTreeNodeBean implements SqlTreeRoot {
|
||||
|
||||
private final TableJoin includeJoin;
|
||||
|
||||
private final boolean sqlDistinct;
|
||||
|
||||
private final String baseTable;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,24 +10,16 @@ import java.util.List;
|
||||
/**
|
||||
* The select properties for a node in the SqlTree.
|
||||
*/
|
||||
public class SqlTreeProperties {
|
||||
public final class SqlTreeProperties {
|
||||
|
||||
/**
|
||||
* The bean properties in order.
|
||||
*/
|
||||
private final List<STreeProperty> propsList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Maintain a list of property names to detect embedded bean additions.
|
||||
*/
|
||||
private final LinkedHashSet<String> propNames = new LinkedHashSet<>();
|
||||
|
||||
private boolean allProperties;
|
||||
|
||||
private boolean aggregationManyToOne;
|
||||
|
||||
private boolean aggregation;
|
||||
|
||||
private String aggregationPath;
|
||||
|
||||
SqlTreeProperties() {
|
||||
|
||||
@@ -15,14 +15,12 @@ import io.ebeaninternal.api.SpiCancelableQuery;
|
||||
*/
|
||||
public class AbstractQuery implements SpiCancelableQuery {
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private boolean cancelled;
|
||||
|
||||
private CancelableQuery cancelableQuery;
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
public final void cancel() {
|
||||
lock.lock();
|
||||
try {
|
||||
if (!cancelled) {
|
||||
@@ -37,14 +35,14 @@ public class AbstractQuery implements SpiCancelableQuery {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCancelled() {
|
||||
public final void checkCancelled() {
|
||||
if (cancelled) {
|
||||
throw new PersistenceException("Query was cancelled");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelableQuery(CancelableQuery cancelableQuery) {
|
||||
public final void setCancelableQuery(CancelableQuery cancelableQuery) {
|
||||
lock.lock();
|
||||
try {
|
||||
checkCancelled();
|
||||
|
||||
@@ -21,35 +21,20 @@ import java.util.stream.Stream;
|
||||
/**
|
||||
* Default implementation of DtoQuery.
|
||||
*/
|
||||
public class DefaultDtoQuery<T> extends AbstractQuery implements SpiDtoQuery<T> {
|
||||
public final class DefaultDtoQuery<T> extends AbstractQuery implements SpiDtoQuery<T> {
|
||||
|
||||
private final SpiEbeanServer server;
|
||||
|
||||
private final DtoBeanDescriptor<T> descriptor;
|
||||
|
||||
private final SpiQuery<?> ormQuery;
|
||||
|
||||
private String sql;
|
||||
|
||||
private int firstRow;
|
||||
|
||||
private int maxRows;
|
||||
|
||||
private int timeout;
|
||||
|
||||
private int bufferFetchSizeHint;
|
||||
|
||||
private boolean relaxedMode;
|
||||
|
||||
private String label;
|
||||
|
||||
private ProfileLocation profileLocation;
|
||||
|
||||
/**
|
||||
* Bind parameters when using the query language.
|
||||
*/
|
||||
private final BindParams bindParams = new BindParams();
|
||||
|
||||
private Transaction transaction;
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,77 +32,47 @@ import java.util.stream.Stream;
|
||||
/**
|
||||
* Default implementation of an Object Relational query.
|
||||
*/
|
||||
public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
|
||||
public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
|
||||
|
||||
private static final String DEFAULT_QUERY_NAME = "default";
|
||||
|
||||
private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache();
|
||||
|
||||
private static final FetchConfig FETCH_QUERY = FetchConfig.ofQuery();
|
||||
|
||||
private static final FetchConfig FETCH_LAZY = FetchConfig.ofLazy();
|
||||
|
||||
private final Class<T> beanType;
|
||||
|
||||
private final ExpressionFactory expressionFactory;
|
||||
|
||||
private final BeanDescriptor<T> rootBeanDescriptor;
|
||||
|
||||
private BeanDescriptor<T> beanDescriptor;
|
||||
|
||||
private SpiEbeanServer server;
|
||||
|
||||
private SpiTransaction transaction;
|
||||
|
||||
/**
|
||||
* For lazy loading of ManyToMany we need to add a join to the intersection table. This is that
|
||||
* join to the intersection table.
|
||||
*/
|
||||
private TableJoin m2mIncludeJoin;
|
||||
|
||||
private ProfilingListener profilingListener;
|
||||
|
||||
private Type type;
|
||||
|
||||
private String label;
|
||||
|
||||
private Mode mode = Mode.NORMAL;
|
||||
|
||||
private Object tenantId;
|
||||
|
||||
/**
|
||||
* Holds query in structured form.
|
||||
*/
|
||||
private OrmQueryDetail detail;
|
||||
|
||||
private int maxRows;
|
||||
|
||||
private int firstRow;
|
||||
|
||||
/**
|
||||
* Set to true to disable lazy loading on the object graph returned.
|
||||
*/
|
||||
private boolean disableLazyLoading;
|
||||
|
||||
/**
|
||||
* Lazy loading batch size (can override server wide default).
|
||||
*/
|
||||
private int lazyLoadBatchSize;
|
||||
|
||||
private OrderBy<T> orderBy;
|
||||
|
||||
private String loadMode;
|
||||
|
||||
private String loadDescription;
|
||||
|
||||
private String generatedSql;
|
||||
|
||||
private String lazyLoadProperty;
|
||||
|
||||
private String lazyLoadManyPath;
|
||||
|
||||
private boolean allowLoadErrors;
|
||||
|
||||
/**
|
||||
* Flag set for report/DTO beans when we may choose to explicitly include the Id property.
|
||||
*/
|
||||
@@ -141,97 +111,55 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
|
||||
* Bind parameters when using the query language.
|
||||
*/
|
||||
private BindParams bindParams;
|
||||
|
||||
private DefaultExpressionList<T> textExpressions;
|
||||
|
||||
private DefaultExpressionList<T> whereExpressions;
|
||||
|
||||
private DefaultExpressionList<T> havingExpressions;
|
||||
|
||||
private boolean asOfBaseTable;
|
||||
|
||||
private int asOfTableCount;
|
||||
|
||||
/**
|
||||
* Set for flashback style 'as of' query.
|
||||
*/
|
||||
private Timestamp asOf;
|
||||
|
||||
private TemporalMode temporalMode = TemporalMode.CURRENT;
|
||||
|
||||
private Timestamp versionsStart;
|
||||
private Timestamp versionsEnd;
|
||||
|
||||
private List<String> softDeletePredicates;
|
||||
|
||||
private boolean disableReadAudit;
|
||||
|
||||
private int bufferFetchSizeHint;
|
||||
|
||||
private boolean usageProfiling = true;
|
||||
|
||||
private CacheMode useBeanCache = CacheMode.AUTO;
|
||||
|
||||
private CacheMode useQueryCache = CacheMode.OFF;
|
||||
|
||||
private Boolean readOnly;
|
||||
|
||||
private PersistenceContextScope persistenceContextScope;
|
||||
|
||||
/**
|
||||
* Allow for explicit on off or null for default.
|
||||
*/
|
||||
private Boolean autoTune;
|
||||
|
||||
private LockWait forUpdate;
|
||||
private LockType lockType;
|
||||
|
||||
private boolean singleAttribute;
|
||||
|
||||
private CountDistinctOrder countDistinctOrder;
|
||||
|
||||
/**
|
||||
* Set to true if this query has been tuned by autoTune.
|
||||
*/
|
||||
private boolean autoTuned;
|
||||
|
||||
/**
|
||||
* Root table alias. For {@link Query#alias(String)} command.
|
||||
*/
|
||||
private String rootTableAlias;
|
||||
|
||||
private String baseTable;
|
||||
|
||||
/**
|
||||
* The node of the bean or collection that fired lazy loading. Not null if profiling is on and
|
||||
* this query is for lazy loading. Used to hook back a lazy loading query to the "original" query
|
||||
* point.
|
||||
*/
|
||||
private ObjectGraphNode parentNode;
|
||||
|
||||
private BeanPropertyAssocMany<?> lazyLoadForParentsProperty;
|
||||
|
||||
/**
|
||||
* Hash of final query after AutoTune tuning.
|
||||
*/
|
||||
private CQueryPlanKey queryPlanKey;
|
||||
|
||||
private PersistenceContext persistenceContext;
|
||||
|
||||
private ManyWhereJoins manyWhereJoins;
|
||||
|
||||
private SpiRawSql rawSql;
|
||||
|
||||
private boolean useDocStore;
|
||||
|
||||
private String docIndexName;
|
||||
|
||||
private OrmUpdateProperties updateProperties;
|
||||
|
||||
private String nativeSql;
|
||||
|
||||
private boolean orderById;
|
||||
|
||||
private ProfileLocation profileLocation;
|
||||
|
||||
public DefaultOrmQuery(BeanDescriptor<T> desc, SpiEbeanServer server, ExpressionFactory expressionFactory) {
|
||||
|
||||
@@ -14,41 +14,21 @@ public final class DefaultOrmUpdate<T> implements SpiUpdate<T>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8791423602246515438L;
|
||||
|
||||
|
||||
private transient final EbeanServer server;
|
||||
|
||||
private final Class<?> beanType;
|
||||
|
||||
/**
|
||||
* The name of the update.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* The parameters used to bind to the sql.
|
||||
*/
|
||||
private final BindParams bindParams = new BindParams();
|
||||
|
||||
/**
|
||||
* The sql update or delete statement.
|
||||
*/
|
||||
private final String updateStatement;
|
||||
|
||||
/**
|
||||
* Automatically detect the table being modified by this sql. This will
|
||||
* register this information so that eBean invalidates cached objects if
|
||||
* required.
|
||||
*/
|
||||
private boolean notifyCache = true;
|
||||
|
||||
private int timeout;
|
||||
|
||||
private String generatedSql;
|
||||
|
||||
private final String baseTable;
|
||||
|
||||
private final OrmUpdateType type;
|
||||
|
||||
/**
|
||||
|
||||
+1
-11
@@ -17,27 +17,17 @@ import java.util.function.Predicate;
|
||||
/**
|
||||
* Default implementation of SQuery - SQL Query.
|
||||
*/
|
||||
public class DefaultRelationalQuery extends AbstractQuery implements SpiSqlQuery {
|
||||
public final class DefaultRelationalQuery extends AbstractQuery implements SpiSqlQuery {
|
||||
|
||||
private static final long serialVersionUID = -1098305779779591068L;
|
||||
|
||||
private final transient SpiEbeanServer server;
|
||||
|
||||
private final String query;
|
||||
|
||||
private String label;
|
||||
|
||||
private int firstRow;
|
||||
|
||||
private int maxRows;
|
||||
|
||||
private int timeout;
|
||||
|
||||
private int bufferFetchSizeHint;
|
||||
|
||||
/**
|
||||
* Bind parameters when using the query language.
|
||||
*/
|
||||
private final BindParams bindParams = new BindParams();
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
/**
|
||||
* Default implementation of UpdateQuery.
|
||||
*/
|
||||
public class DefaultUpdateQuery<T> implements UpdateQuery<T> {
|
||||
public final class DefaultUpdateQuery<T> implements UpdateQuery<T> {
|
||||
|
||||
private final OrmUpdateProperties values = new OrmUpdateProperties();
|
||||
private final DefaultOrmQuery<T> query;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package io.ebeaninternal.server.querydefn;
|
||||
|
||||
public class NaturalKeyBindParam {
|
||||
public final class NaturalKeyBindParam {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Object value;
|
||||
|
||||
public NaturalKeyBindParam(String name, Object value) {
|
||||
|
||||
@@ -7,10 +7,9 @@ import javax.persistence.PersistenceException;
|
||||
/**
|
||||
* Named parameter used as placeholder in expressions created by EQL language parsing.
|
||||
*/
|
||||
class ONamedParam implements SpiNamedParam {
|
||||
final class ONamedParam implements SpiNamedParam {
|
||||
|
||||
private final String name;
|
||||
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.*;
|
||||
* Tuning a query is a matter of replacing an instance of this class with one that has been tuned
|
||||
* with select() and join() set.
|
||||
*/
|
||||
public class OrmQueryDetail implements Serializable {
|
||||
public final class OrmQueryDetail implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2510486880141461807L;
|
||||
|
||||
|
||||
+1
-4
@@ -9,10 +9,9 @@ import javax.persistence.PersistenceException;
|
||||
* replace the OrmQueryDetail leaving the attributes unchanged.
|
||||
* </p>
|
||||
*/
|
||||
public class OrmQueryDetailParser {
|
||||
public final class OrmQueryDetailParser {
|
||||
|
||||
private final OrmQueryDetail detail = new OrmQueryDetail();
|
||||
|
||||
private final SimpleTextParser parser;
|
||||
|
||||
public OrmQueryDetailParser(String oql) {
|
||||
@@ -20,7 +19,6 @@ public class OrmQueryDetailParser {
|
||||
}
|
||||
|
||||
public OrmQueryDetail parse() throws PersistenceException {
|
||||
|
||||
if (parser.isEmpty()) return detail;
|
||||
|
||||
parser.nextWord();
|
||||
@@ -68,7 +66,6 @@ public class OrmQueryDetailParser {
|
||||
}
|
||||
|
||||
private OrmQueryProperties readFindFetch() {
|
||||
|
||||
boolean readAlias = false;
|
||||
|
||||
String props = null;
|
||||
|
||||
+1
-5
@@ -4,16 +4,12 @@ import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.SqlLimitRequest;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
|
||||
public class OrmQueryLimitRequest implements SqlLimitRequest {
|
||||
public final class OrmQueryLimitRequest implements SqlLimitRequest {
|
||||
|
||||
private final SpiQuery<?> ormQuery;
|
||||
|
||||
private final DatabasePlatform dbPlatform;
|
||||
|
||||
private final String sql;
|
||||
|
||||
private final String sqlOrderBy;
|
||||
|
||||
private final boolean distinct;
|
||||
|
||||
public OrmQueryLimitRequest(String sql, String sqlOrderBy, SpiQuery<?> ormQuery, DatabasePlatform dbPlatform, boolean distinct) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* Query plan key for ORM queries.
|
||||
*/
|
||||
class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
final class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
|
||||
private final SpiRawSql.Key rawSqlKey;
|
||||
private final int maxRows;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Represents the Properties of an Object Relational query.
|
||||
*/
|
||||
public class OrmQueryProperties implements Serializable {
|
||||
public final class OrmQueryProperties implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8785582703966455658L;
|
||||
|
||||
@@ -35,30 +35,24 @@ public class OrmQueryProperties implements Serializable {
|
||||
private final Set<String> included;
|
||||
private final FetchConfig fetchConfig;
|
||||
private final boolean cache;
|
||||
|
||||
/**
|
||||
* Flag set when this fetch path needs to be a query join.
|
||||
*/
|
||||
private boolean markForQueryJoin;
|
||||
|
||||
/**
|
||||
* Included bean joins.
|
||||
*/
|
||||
private Set<String> includedBeanJoin;
|
||||
|
||||
/**
|
||||
* Add these properties to the select so that the foreign key columns are included in the query.
|
||||
*/
|
||||
private Set<String> secondaryQueryJoins;
|
||||
|
||||
private List<OrmQueryProperties> secondaryChildren;
|
||||
|
||||
/**
|
||||
* OrderBy properties that where on the main query but moved here as they relate to this (query join).
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
private OrderBy orderBy;
|
||||
|
||||
/**
|
||||
* A filter that can be applied to the fetch of this path in the object graph.
|
||||
*/
|
||||
|
||||
@@ -7,10 +7,9 @@ import java.util.List;
|
||||
/**
|
||||
* The secondary query paths for 'query joins' and 'lazy loading'.
|
||||
*/
|
||||
class OrmQuerySecondary implements SpiQuerySecondary {
|
||||
final class OrmQuerySecondary implements SpiQuerySecondary {
|
||||
|
||||
private final List<OrmQueryProperties> queryJoins;
|
||||
|
||||
private final List<OrmQueryProperties> lazyJoins;
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,10 +13,9 @@ import java.util.Set;
|
||||
/**
|
||||
* Set properties for a UpdateQuery.
|
||||
*/
|
||||
public class OrmUpdateProperties {
|
||||
public final class OrmUpdateProperties {
|
||||
|
||||
private static final NullValue NULL_VALUE = new NullValue();
|
||||
|
||||
private static final NoneValue NONE_VALUE = new NoneValue();
|
||||
|
||||
/**
|
||||
@@ -41,7 +40,7 @@ public class OrmUpdateProperties {
|
||||
/**
|
||||
* Set property to null.
|
||||
*/
|
||||
private static class NullValue extends Value {
|
||||
private static final class NullValue extends Value {
|
||||
@Override
|
||||
public String bindClause() {
|
||||
return "=null";
|
||||
@@ -51,7 +50,7 @@ public class OrmUpdateProperties {
|
||||
/**
|
||||
* Set property to a simple value.
|
||||
*/
|
||||
private static class SimpleValue extends Value {
|
||||
private static final class SimpleValue extends Value {
|
||||
|
||||
final Object value;
|
||||
final ScalarType<Object> scalarType;
|
||||
@@ -85,7 +84,7 @@ public class OrmUpdateProperties {
|
||||
/**
|
||||
* Set using an expression with no bind value.
|
||||
*/
|
||||
private static class NoneValue extends Value {
|
||||
private static final class NoneValue extends Value {
|
||||
@Override
|
||||
public String bindClause() {
|
||||
return "";
|
||||
@@ -95,7 +94,7 @@ public class OrmUpdateProperties {
|
||||
/**
|
||||
* Set using an expression with many bind values.
|
||||
*/
|
||||
private static class RawArrayValue extends Value {
|
||||
private static final class RawArrayValue extends Value {
|
||||
|
||||
final Object[] bindValues;
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package io.ebeaninternal.server.querydefn;
|
||||
|
||||
public class SimpleTextParser {
|
||||
public final class SimpleTextParser {
|
||||
|
||||
private final String oql;
|
||||
private final char[] chars;
|
||||
private final int eof;
|
||||
|
||||
private int pos;
|
||||
private String word;
|
||||
private String lowerWord;
|
||||
|
||||
Reference in New Issue
Block a user