mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor rename internal methods for SpiQueryPlan and DbReadContext
Change the getter methods to use accessor style
This commit is contained in:
@@ -10,27 +10,27 @@ public interface SpiQueryPlan {
|
||||
/**
|
||||
* The related entity bean type
|
||||
*/
|
||||
Class<?> getBeanType();
|
||||
Class<?> beanType();
|
||||
|
||||
/**
|
||||
* The plan name.
|
||||
*/
|
||||
String getName();
|
||||
String name();
|
||||
|
||||
/**
|
||||
* The hash of the sql.
|
||||
*/
|
||||
String getHash();
|
||||
String hash();
|
||||
|
||||
/**
|
||||
* The SQL for the query plan.
|
||||
*/
|
||||
String getSql();
|
||||
String sql();
|
||||
|
||||
/**
|
||||
* The related profile location.
|
||||
*/
|
||||
ProfileLocation getProfileLocation();
|
||||
ProfileLocation profileLocation();
|
||||
|
||||
/**
|
||||
* Initiate bind capture with the give threshold.
|
||||
|
||||
@@ -61,7 +61,7 @@ abstract class AssocOneHelp {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
PersistenceContext pc = ctx.getPersistenceContext();
|
||||
PersistenceContext pc = ctx.persistenceContext();
|
||||
Object existing = target.contextGet(pc, id);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
|
||||
@@ -22,7 +22,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
@Override
|
||||
void loadIgnore(DbReadContext ctx) {
|
||||
property.targetIdBinder.loadIgnore(ctx);
|
||||
ctx.getDataReader().incrementPos(1);
|
||||
ctx.dataReader().incrementPos(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
return null;
|
||||
}
|
||||
// check transaction context to see if it already exists
|
||||
PersistenceContext pc = ctx.getPersistenceContext();
|
||||
PersistenceContext pc = ctx.persistenceContext();
|
||||
Object existing = desc.contextGet(pc, id);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
|
||||
@@ -1468,7 +1468,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
|
||||
void queryPlanInit(QueryPlanInit request, List<MetaQueryPlan> list) {
|
||||
for (CQueryPlan queryPlan : queryPlanCache.values()) {
|
||||
if (request.includeHash(queryPlan.getHash())) {
|
||||
if (request.includeHash(queryPlan.hash())) {
|
||||
queryPlan.queryPlanInit(request.thresholdMicros());
|
||||
list.add(queryPlan.createMeta(null, null));
|
||||
}
|
||||
@@ -1500,7 +1500,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
* Trim query plans not used since the passed in epoch time.
|
||||
*/
|
||||
void trimQueryPlans(long unusedSince) {
|
||||
queryPlanCache.values().removeIf(queryPlan -> queryPlan.getLastQueryTime() < unusedSince);
|
||||
queryPlanCache.values().removeIf(queryPlan -> queryPlan.lastQueryTime() < unusedSince);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -506,7 +506,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
|
||||
@Override
|
||||
public void loadIgnore(DbReadContext ctx) {
|
||||
scalarType.loadIgnore(ctx.getDataReader());
|
||||
scalarType.loadIgnore(ctx.dataReader());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -541,11 +541,11 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
public Object read(DbReadContext ctx) throws SQLException {
|
||||
return scalarType.read(ctx.getDataReader());
|
||||
return scalarType.read(ctx.dataReader());
|
||||
}
|
||||
|
||||
public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException {
|
||||
return readSet(ctx.getDataReader(), bean);
|
||||
return readSet(ctx.dataReader(), bean);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface DbReadContext {
|
||||
/**
|
||||
* Return the DataReader.
|
||||
*/
|
||||
DataReader getDataReader();
|
||||
DataReader dataReader();
|
||||
|
||||
/**
|
||||
* Return true if the query is using supplied SQL rather than generated SQL.
|
||||
@@ -52,7 +52,7 @@ public interface DbReadContext {
|
||||
/**
|
||||
* Return the persistence context.
|
||||
*/
|
||||
PersistenceContext getPersistenceContext();
|
||||
PersistenceContext persistenceContext();
|
||||
|
||||
/**
|
||||
* Register a reference for lazy loading.
|
||||
@@ -69,7 +69,6 @@ public interface DbReadContext {
|
||||
*/
|
||||
void register(BeanPropertyAssocMany<?> many, BeanCollection<?> bc);
|
||||
|
||||
|
||||
/**
|
||||
* Set back the bean that has just been loaded with its id.
|
||||
*/
|
||||
@@ -78,7 +77,7 @@ public interface DbReadContext {
|
||||
/**
|
||||
* Return the query mode.
|
||||
*/
|
||||
SpiQuery.Mode getQueryMode();
|
||||
SpiQuery.Mode queryMode();
|
||||
|
||||
/**
|
||||
* Return true if the underlying query is a 'asDraft' query.
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
|
||||
public void load(SqlBeanLoad sqlBeanLoad) {
|
||||
Object value;
|
||||
try {
|
||||
value = scalarType.read(sqlBeanLoad.ctx().getDataReader());
|
||||
value = scalarType.read(sqlBeanLoad.ctx().dataReader());
|
||||
} catch (Exception e) {
|
||||
sqlBeanLoad.ctx().handleLoadError(fullName, e);
|
||||
return;
|
||||
|
||||
@@ -65,7 +65,7 @@ abstract class DynamicPropertyBase implements STreeProperty {
|
||||
|
||||
@Override
|
||||
public void loadIgnore(DbReadContext ctx) {
|
||||
scalarType.loadIgnore(ctx.getDataReader());
|
||||
scalarType.loadIgnore(ctx.dataReader());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -197,7 +197,7 @@ public final class InheritInfo {
|
||||
* Return the associated InheritInfo for this DB row read.
|
||||
*/
|
||||
public InheritInfo readType(DbReadContext ctx) throws SQLException {
|
||||
return readType(ctx.getDataReader().getString());
|
||||
return readType(ctx.dataReader().getString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -57,8 +57,8 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
|
||||
@Override
|
||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||
CQuery<?> subQuery = compileSubQuery(request);
|
||||
this.bindParams = subQuery.getPredicates().getWhereExprBindValues();
|
||||
this.sql = subQuery.getGeneratedSql().replace('\n', ' ');
|
||||
this.bindParams = subQuery.predicates().getWhereExprBindValues();
|
||||
this.sql = subQuery.generatedSql().replace('\n', ' ');
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,8 +45,8 @@ final class InQueryExpression extends AbstractExpression implements UnsupportedD
|
||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||
|
||||
CQuery<?> subQuery = compileSubQuery(request);
|
||||
this.bindParams = subQuery.getPredicates().getWhereExprBindValues();
|
||||
this.sql = subQuery.getGeneratedSql().replace('\n', ' ');
|
||||
this.bindParams = subQuery.predicates().getWhereExprBindValues();
|
||||
this.sql = subQuery.generatedSql().replace('\n', ' ');
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -188,13 +188,13 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
this.autoTuneProfiling = profilingListener != null;
|
||||
// set the generated sql back to the query
|
||||
// so its available to the user...
|
||||
query.setGeneratedSql(queryPlan.getSql());
|
||||
SqlTreePlan sqlTree = queryPlan.getSqlTree();
|
||||
query.setGeneratedSql(queryPlan.sql());
|
||||
SqlTreePlan sqlTree = queryPlan.sqlTree();
|
||||
this.rootNode = sqlTree.getRootNode();
|
||||
this.manyProperty = sqlTree.getManyProperty();
|
||||
this.sql = queryPlan.getSql();
|
||||
this.sql = queryPlan.sql();
|
||||
this.rawSql = queryPlan.isRawSql();
|
||||
this.logWhereSql = queryPlan.getLogWhereSql();
|
||||
this.logWhereSql = queryPlan.logWhereSql();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
if (lazyLoadManyProperty != null) {
|
||||
@@ -243,20 +243,20 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataReader getDataReader() {
|
||||
public DataReader dataReader() {
|
||||
return dataReader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode getQueryMode() {
|
||||
public Mode queryMode() {
|
||||
return queryMode;
|
||||
}
|
||||
|
||||
public CQueryPredicates getPredicates() {
|
||||
public CQueryPredicates predicates() {
|
||||
return predicates;
|
||||
}
|
||||
|
||||
SpiOrmQueryRequest<?> getQueryRequest() {
|
||||
SpiOrmQueryRequest<?> request() {
|
||||
return request;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
* Return the persistence context.
|
||||
*/
|
||||
@Override
|
||||
public PersistenceContext getPersistenceContext() {
|
||||
public PersistenceContext persistenceContext() {
|
||||
return request.persistenceContext();
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
if (lazyLoadParentId != null) {
|
||||
if (!lazyLoadParentId.equals(this.lazyLoadParentId)) {
|
||||
// get the appropriate parent bean from the persistence context
|
||||
this.lazyLoadParentBean = (EntityBean) lazyLoadManyProperty.descriptor().contextGet(getPersistenceContext(), lazyLoadParentId);
|
||||
this.lazyLoadParentBean = (EntityBean) lazyLoadManyProperty.descriptor().contextGet(persistenceContext(), lazyLoadParentId);
|
||||
this.lazyLoadParentId = lazyLoadParentId;
|
||||
}
|
||||
// add the loadedBean to the appropriate collection of lazyLoadParentBean
|
||||
@@ -451,7 +451,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
return true;
|
||||
}
|
||||
|
||||
long getQueryExecutionTimeMicros() {
|
||||
long queryExecutionTimeMicros() {
|
||||
return executionTimeMicros;
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
if (queryPlan.executionTime(executionTimeMicros)) {
|
||||
queryPlan.captureBindForQueryPlan(predicates, executionTimeMicros);
|
||||
}
|
||||
getTransaction().profileEvent(this);
|
||||
transaction().profileEvent(this);
|
||||
} catch (Exception e) {
|
||||
CoreLog.log.error("Error updating execution statistics", e);
|
||||
}
|
||||
@@ -554,7 +554,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
|
||||
@Override
|
||||
public void profile() {
|
||||
getTransaction()
|
||||
transaction()
|
||||
.profileStream()
|
||||
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), loadedBeanCount, query.getProfileId());
|
||||
}
|
||||
@@ -567,7 +567,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
}
|
||||
}
|
||||
|
||||
String getLoadedRowDetail() {
|
||||
String loadedRowDetail() {
|
||||
if (manyProperty == null) {
|
||||
return String.valueOf(rowCount);
|
||||
} else {
|
||||
@@ -601,30 +601,29 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
/**
|
||||
* Return the where predicate for display in the transaction log.
|
||||
*/
|
||||
String getLogWhereSql() {
|
||||
String logWhereSql() {
|
||||
return logWhereSql;
|
||||
}
|
||||
|
||||
|
||||
public String getBindLog() {
|
||||
public String bindLog() {
|
||||
return bindLog;
|
||||
}
|
||||
|
||||
public SpiTransaction getTransaction() {
|
||||
public SpiTransaction transaction() {
|
||||
return request.transaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the short bean name.
|
||||
*/
|
||||
String getBeanName() {
|
||||
String beanName() {
|
||||
return desc.name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the generated sql.
|
||||
*/
|
||||
public String getGeneratedSql() {
|
||||
public String generatedSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -676,7 +675,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
void auditFind(EntityBean bean) {
|
||||
if (bean != null) {
|
||||
// only audit when a bean was actually found
|
||||
desc.readAuditBean(queryPlan.getAuditQueryKey(), bindLog, bean);
|
||||
desc.readAuditBean(queryPlan.auditQueryKey(), bindLog, bean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,11 +688,11 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
ReadEvent futureReadEvent = query.getFutureFetchAudit();
|
||||
if (futureReadEvent == null) {
|
||||
// normal query execution
|
||||
desc.readAuditMany(queryPlan.getAuditQueryKey(), bindLog, auditIds);
|
||||
desc.readAuditMany(queryPlan.auditQueryKey(), bindLog, auditIds);
|
||||
} else {
|
||||
// this query was executed via findFutureList() and the prepare()
|
||||
// has already been called so set the details and log
|
||||
futureReadEvent.setQueryKey(queryPlan.getAuditQueryKey());
|
||||
futureReadEvent.setQueryKey(queryPlan.auditQueryKey());
|
||||
futureReadEvent.setBindLog(bindLog);
|
||||
futureReadEvent.setIds(auditIds);
|
||||
desc.readAuditFutureMany(futureReadEvent);
|
||||
@@ -712,7 +711,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
* Send the current buffer of findIterate collected ids to the audit log.
|
||||
*/
|
||||
private void auditIterateLogMessage() {
|
||||
desc.readAuditMany(queryPlan.getAuditQueryKey(), bindLog, auditIds);
|
||||
desc.readAuditMany(queryPlan.auditQueryKey(), bindLog, auditIds);
|
||||
// create a new list on demand with the next bean/id
|
||||
auditIds = null;
|
||||
}
|
||||
@@ -733,7 +732,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
/**
|
||||
* Return the underlying PreparedStatement.
|
||||
*/
|
||||
PreparedStatement getPstmt() {
|
||||
PreparedStatement pstmt() {
|
||||
return pstmt;
|
||||
}
|
||||
|
||||
@@ -742,7 +741,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
query.handleLoadError(fullName, e);
|
||||
}
|
||||
|
||||
public Set<String> getDependentTables() {
|
||||
return queryPlan.getDependentTables();
|
||||
public Set<String> dependentTables() {
|
||||
return queryPlan.dependentTables();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ final class CQueryBuilder {
|
||||
BeanDescriptor<T> desc = request.descriptor();
|
||||
if (desc.isReadAuditing()) {
|
||||
// log the query plan based bean type (i.e. ignoring query disabling for logging the sql/plan)
|
||||
desc.readAuditLogger().queryPlan(new ReadAuditQueryPlan(desc.fullName(), queryPlan.getAuditQueryKey(), queryPlan.getSql()));
|
||||
desc.readAuditLogger().queryPlan(new ReadAuditQueryPlan(desc.fullName(), queryPlan.auditQueryKey(), queryPlan.sql()));
|
||||
}
|
||||
// cache the query plan because we can reuse it and also
|
||||
// gather query performance statistics based on it.
|
||||
|
||||
@@ -331,10 +331,10 @@ public final class CQueryEngine {
|
||||
if (request.logSql()) {
|
||||
logSql(cquery);
|
||||
}
|
||||
return new SpiResultSet(cquery.getPstmt(), resultSet);
|
||||
return new SpiResultSet(cquery.pstmt(), resultSet);
|
||||
|
||||
} catch (SQLException e) {
|
||||
JdbcClose.close(cquery.getPstmt());
|
||||
JdbcClose.close(cquery.pstmt());
|
||||
throw cquery.createPersistenceException(e);
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,7 @@ public final class CQueryEngine {
|
||||
}
|
||||
request.executeSecondaryQueries(false);
|
||||
if (request.isQueryCachePut()) {
|
||||
request.addDependentTables(cquery.getDependentTables());
|
||||
request.addDependentTables(cquery.dependentTables());
|
||||
}
|
||||
return beanCollection;
|
||||
|
||||
@@ -414,14 +414,14 @@ public final class CQueryEngine {
|
||||
* Log the generated SQL to the transaction log.
|
||||
*/
|
||||
private void logSql(CQuery<?> query) {
|
||||
query.getTransaction().logSql(Str.add(query.getGeneratedSql(), "; --bind(", query.getBindLog(), ") --micros(", query.micros() + ")"));
|
||||
query.transaction().logSql(Str.add(query.generatedSql(), "; --bind(", query.bindLog(), ") --micros(", query.micros() + ")"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the FindById summary to the transaction log.
|
||||
*/
|
||||
private void logFindBeanSummary(CQuery<?> q) {
|
||||
SpiQuery<?> query = q.getQueryRequest().query();
|
||||
SpiQuery<?> query = q.request().query();
|
||||
String loadMode = query.getLoadMode();
|
||||
String loadDesc = query.getLoadDescription();
|
||||
String lazyLoadProp = query.getLazyLoadProperty();
|
||||
@@ -438,7 +438,7 @@ public final class CQueryEngine {
|
||||
if (loadMode != null) {
|
||||
msg.append("mode[").append(loadMode).append("] ");
|
||||
}
|
||||
msg.append("type[").append(q.getBeanName()).append("] ");
|
||||
msg.append("type[").append(q.beanName()).append("] ");
|
||||
if (query.isAutoTuned()) {
|
||||
msg.append("tuned[true] ");
|
||||
}
|
||||
@@ -454,17 +454,17 @@ public final class CQueryEngine {
|
||||
if (loadDesc != null) {
|
||||
msg.append("load[").append(loadDesc).append("] ");
|
||||
}
|
||||
msg.append("exeMicros[").append(q.getQueryExecutionTimeMicros());
|
||||
msg.append("] rows[").append(q.getLoadedRowDetail());
|
||||
msg.append("] bind[").append(q.getBindLog()).append("]");
|
||||
q.getTransaction().logSummary(msg.toString());
|
||||
msg.append("exeMicros[").append(q.queryExecutionTimeMicros());
|
||||
msg.append("] rows[").append(q.loadedRowDetail());
|
||||
msg.append("] bind[").append(q.bindLog()).append("]");
|
||||
q.transaction().logSummary(msg.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the FindMany to the transaction log.
|
||||
*/
|
||||
private void logFindManySummary(CQuery<?> q) {
|
||||
SpiQuery<?> query = q.getQueryRequest().query();
|
||||
SpiQuery<?> query = q.request().query();
|
||||
String loadMode = query.getLoadMode();
|
||||
String loadDesc = query.getLoadDescription();
|
||||
String lazyLoadProp = query.getLazyLoadProperty();
|
||||
@@ -482,7 +482,7 @@ public final class CQueryEngine {
|
||||
if (loadMode != null) {
|
||||
msg.append("mode[").append(loadMode).append("] ");
|
||||
}
|
||||
msg.append("type[").append(q.getBeanName()).append("] ");
|
||||
msg.append("type[").append(q.beanName()).append("] ");
|
||||
if (query.isAutoTuned()) {
|
||||
msg.append("tuned[true] ");
|
||||
}
|
||||
@@ -498,10 +498,10 @@ public final class CQueryEngine {
|
||||
if (loadDesc != null) {
|
||||
msg.append("load[").append(loadDesc).append("] ");
|
||||
}
|
||||
msg.append("exeMicros[").append(q.getQueryExecutionTimeMicros());
|
||||
msg.append("] rows[").append(q.getLoadedRowDetail());
|
||||
msg.append("] predicates[").append(q.getLogWhereSql());
|
||||
msg.append("] bind[").append(q.getBindLog()).append("]");
|
||||
q.getTransaction().logSummary(msg.toString());
|
||||
msg.append("exeMicros[").append(q.queryExecutionTimeMicros());
|
||||
msg.append("] rows[").append(q.loadedRowDetail());
|
||||
msg.append("] predicates[").append(q.logWhereSql());
|
||||
msg.append("] bind[").append(q.bindLog()).append("]");
|
||||
q.transaction().logSummary(msg.toString());
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -15,9 +15,7 @@ import io.ebeaninternal.server.type.RsetDataReader;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@@ -49,11 +47,11 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
this.request = request;
|
||||
this.queryPlan = queryPlan;
|
||||
this.query = request.query();
|
||||
this.sql = queryPlan.getSql();
|
||||
this.sql = queryPlan.sql();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
this.containsCounts = containsCounts;
|
||||
this.reader = queryPlan.getSingleAttributeScalarType();
|
||||
this.reader = queryPlan.singleAttributeScalarType();
|
||||
query.setGeneratedSql(sql);
|
||||
}
|
||||
|
||||
@@ -168,7 +166,7 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
}
|
||||
|
||||
Set<String> getDependentTables() {
|
||||
return queryPlan.getDependentTables();
|
||||
return queryPlan.dependentTables();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -157,39 +157,39 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Class<?> getBeanType() {
|
||||
public final Class<?> beanType() {
|
||||
return beanType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getName() {
|
||||
public final String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getHash() {
|
||||
public final String hash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSql() {
|
||||
public final String sql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ProfileLocation getProfileLocation() {
|
||||
public final ProfileLocation profileLocation() {
|
||||
return profileLocation;
|
||||
}
|
||||
|
||||
public final String getLabel() {
|
||||
public final String label() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public final Set<String> getDependentTables() {
|
||||
public final Set<String> dependentTables() {
|
||||
return dependentTables;
|
||||
}
|
||||
|
||||
public final String getLocation() {
|
||||
public final String location() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
|
||||
@Override
|
||||
public final DQueryPlanOutput createMeta(String bind, String planString) {
|
||||
return new DQueryPlanOutput(getBeanType(), name, hash, sql, profileLocation, bind, planString);
|
||||
return new DQueryPlanOutput(beanType(), name, hash, sql, profileLocation, bind, planString);
|
||||
}
|
||||
|
||||
public DataReader createDataReader(ResultSet rset) {
|
||||
@@ -230,14 +230,14 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
return dataBind;
|
||||
}
|
||||
|
||||
final int getAsOfTableCount() {
|
||||
final int asOfTableCount() {
|
||||
return asOfTableCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a key used in audit logging to identify the query.
|
||||
*/
|
||||
final String getAuditQueryKey() {
|
||||
final String auditQueryKey() {
|
||||
if (auditQueryHash == null) {
|
||||
// volatile object assignment (so happy for multithreaded access)
|
||||
auditQueryHash = calcAuditQueryKey();
|
||||
@@ -250,7 +250,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
return rawSql ? planKey.getPartialKey() + "_" + hash : planKey.getPartialKey();
|
||||
}
|
||||
|
||||
final SqlTreePlan getSqlTree() {
|
||||
final SqlTreePlan sqlTree() {
|
||||
return sqlTree;
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
return rawSql;
|
||||
}
|
||||
|
||||
final String getLogWhereSql() {
|
||||
final String logWhereSql() {
|
||||
return logWhereSql;
|
||||
}
|
||||
|
||||
@@ -287,11 +287,11 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
/**
|
||||
* Return the time this query plan was last used.
|
||||
*/
|
||||
public final long getLastQueryTime() {
|
||||
public final long lastQueryTime() {
|
||||
return stats.getLastQueryTime();
|
||||
}
|
||||
|
||||
final ScalarDataReader<?> getSingleAttributeScalarType() {
|
||||
final ScalarDataReader<?> singleAttributeScalarType() {
|
||||
return sqlTree.getRootNode().getSingleAttributeReader();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class CQueryPlanStats {
|
||||
}
|
||||
|
||||
String reportName(MetricVisitor visitor) {
|
||||
final String tmp = visitor.namingConvention().apply(queryPlan.getName());
|
||||
final String tmp = visitor.namingConvention().apply(queryPlan.name());
|
||||
this.reportName = tmp;
|
||||
return tmp;
|
||||
}
|
||||
@@ -95,12 +95,12 @@ public final class CQueryPlanStats {
|
||||
|
||||
@Override
|
||||
public Class<?> type() {
|
||||
return queryPlan.getBeanType();
|
||||
return queryPlan.beanType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String label() {
|
||||
return queryPlan.getLabel();
|
||||
return queryPlan.label();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +110,7 @@ public final class CQueryPlanStats {
|
||||
|
||||
@Override
|
||||
public String location() {
|
||||
return queryPlan.getLocation();
|
||||
return queryPlan.location();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,12 +135,12 @@ public final class CQueryPlanStats {
|
||||
|
||||
@Override
|
||||
public String hash() {
|
||||
return queryPlan.getHash();
|
||||
return queryPlan.hash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sql() {
|
||||
return queryPlan.getSql();
|
||||
return queryPlan.sql();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class CQueryPredicates {
|
||||
}
|
||||
CQueryPlan queryPlan = request.queryPlan();
|
||||
if (queryPlan != null) {
|
||||
int asOfTableCount = queryPlan.getAsOfTableCount();
|
||||
int asOfTableCount = queryPlan.asOfTableCount();
|
||||
if (asOfTableCount > 0) {
|
||||
// bind the asOf value for each table alias as part of the from/join clauses
|
||||
// there is one effective date predicate per table alias
|
||||
|
||||
@@ -42,7 +42,7 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
this.queryPlan = queryPlan;
|
||||
this.request = request;
|
||||
this.query = request.query();
|
||||
this.sql = queryPlan.getSql();
|
||||
this.sql = queryPlan.sql();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
query.setGeneratedSql(sql);
|
||||
@@ -141,7 +141,7 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
}
|
||||
|
||||
Set<String> getDependentTables() {
|
||||
return queryPlan.getDependentTables();
|
||||
return queryPlan.dependentTables();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery
|
||||
this.request = request;
|
||||
this.queryPlan = queryPlan;
|
||||
this.query = request.query();
|
||||
this.sql = queryPlan.getSql();
|
||||
this.sql = queryPlan.sql();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
query.setGeneratedSql(sql);
|
||||
|
||||
@@ -17,7 +17,7 @@ public final class QueryPlanLoggerExplain extends QueryPlanLogger {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind) {
|
||||
try (PreparedStatement explainStmt = conn.prepareStatement("EXPLAIN " + plan.getSql())) {
|
||||
try (PreparedStatement explainStmt = conn.prepareStatement("EXPLAIN " + plan.sql())) {
|
||||
bind.prepare(explainStmt, conn);
|
||||
try (ResultSet rset = explainStmt.executeQuery()) {
|
||||
return readQueryPlan(plan, bind, rset);
|
||||
|
||||
@@ -22,7 +22,7 @@ public final class QueryPlanLoggerOracle extends QueryPlanLogger {
|
||||
@Override
|
||||
public SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind) {
|
||||
try (Statement stmt = conn.createStatement()) {
|
||||
try (PreparedStatement explainStmt = conn.prepareStatement("EXPLAIN PLAN FOR " + plan.getSql())) {
|
||||
try (PreparedStatement explainStmt = conn.prepareStatement("EXPLAIN PLAN FOR " + plan.sql())) {
|
||||
bind.prepare(explainStmt, conn);
|
||||
explainStmt.execute();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public final class QueryPlanLoggerPostgres extends QueryPlanLogger {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan collectPlan(Connection conn, SpiQueryPlan plan, BindCapture bind) {
|
||||
String explain = "explain analyze " + plan.getSql();
|
||||
String explain = "explain analyze " + plan.sql();
|
||||
try (PreparedStatement explainStmt = conn.prepareStatement(explain)) {
|
||||
bind.prepare(explainStmt, conn);
|
||||
try (ResultSet rset = explainStmt.executeQuery()) {
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public final class QueryPlanLoggerSqlServer extends QueryPlanLogger {
|
||||
try (Statement stmt = conn.createStatement()) {
|
||||
stmt.execute("set statistics xml on");
|
||||
stmt.execute("begin transaction");
|
||||
try (PreparedStatement explainStmt = conn.prepareStatement(plan.getSql())) {
|
||||
try (PreparedStatement explainStmt = conn.prepareStatement(plan.sql())) {
|
||||
bind.prepare(explainStmt, conn);
|
||||
|
||||
try (ResultSet rset = explainStmt.executeQuery()) {
|
||||
|
||||
@@ -163,8 +163,8 @@ class SqlTreeLoadBean implements SqlTreeLoad {
|
||||
}
|
||||
|
||||
private void initPersistenceContext() {
|
||||
queryMode = ctx.getQueryMode();
|
||||
persistenceContext = (!readIdNormal) ? null : ctx.getPersistenceContext();
|
||||
queryMode = ctx.queryMode();
|
||||
persistenceContext = (!readIdNormal) ? null : ctx.persistenceContext();
|
||||
}
|
||||
|
||||
private void readId() throws SQLException {
|
||||
|
||||
@@ -34,8 +34,8 @@ final class SqlTreeLoadRoot extends SqlTreeLoadBean implements SqlTreeRoot {
|
||||
public <T> Version<T> loadVersion(DbReadContext ctx) throws SQLException {
|
||||
// read the sys period lower and upper bounds
|
||||
// these are always the first 2 columns in the resultSet
|
||||
Timestamp start = ctx.getDataReader().getTimestamp();
|
||||
Timestamp end = ctx.getDataReader().getTimestamp();
|
||||
Timestamp start = ctx.dataReader().getTimestamp();
|
||||
Timestamp end = ctx.dataReader().getTimestamp();
|
||||
T bean = (T) load(ctx, null, null);
|
||||
return new Version<>(bean, start, end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user