mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 05:35:54 +00:00
Merge pull request #2795 from ebean-orm/feature/refactor-methodNames-query
Refactor rename internal methods - io.ebeaninternal.server.query
This commit is contained in:
@@ -9,7 +9,7 @@ public interface CQueryPlanKey {
|
||||
* Used by read audit such that we can log read audit entries without the full sql
|
||||
* (which would make the read audit logs verbose).
|
||||
*/
|
||||
String getPartialKey();
|
||||
String partialKey();
|
||||
|
||||
/**
|
||||
* Return a query plan key taking into account persist cascading.
|
||||
|
||||
@@ -1330,7 +1330,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
copy.setFutureFetch(true);
|
||||
Transaction newTxn = createTransaction();
|
||||
QueryFutureRowCount<T> queryFuture = new QueryFutureRowCount<>(new CallableQueryCount<>(this, copy, newTxn));
|
||||
backgroundExecutor.execute(queryFuture.getFutureTask());
|
||||
backgroundExecutor.execute(queryFuture.futureTask());
|
||||
return queryFuture;
|
||||
}
|
||||
|
||||
@@ -1340,7 +1340,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
copy.setFutureFetch(true);
|
||||
Transaction newTxn = createTransaction();
|
||||
QueryFutureIds<T> queryFuture = new QueryFutureIds<>(new CallableQueryIds<>(this, copy, newTxn));
|
||||
backgroundExecutor.execute(queryFuture.getFutureTask());
|
||||
backgroundExecutor.execute(queryFuture.futureTask());
|
||||
return queryFuture;
|
||||
}
|
||||
|
||||
@@ -1357,7 +1357,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
// Create a new transaction solely to execute the findList() at some future time
|
||||
Transaction newTxn = createTransaction();
|
||||
QueryFutureList<T> queryFuture = new QueryFutureList<>(new CallableQueryList<>(this, spiQuery, newTxn));
|
||||
backgroundExecutor.execute(queryFuture.getFutureTask());
|
||||
backgroundExecutor.execute(queryFuture.futureTask());
|
||||
return queryFuture;
|
||||
}
|
||||
|
||||
|
||||
@@ -639,7 +639,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
for (T bean : actualDetails) {
|
||||
ids.add(beanDescriptor.idForJson(bean));
|
||||
}
|
||||
beanDescriptor.readAuditMany(queryPlanKey.getPartialKey(), "l2-query-cache", ids);
|
||||
beanDescriptor.readAuditMany(queryPlanKey.partialKey(), "l2-query-cache", ids);
|
||||
}
|
||||
}
|
||||
if (Boolean.FALSE.equals(query.isReadOnly())) {
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
||||
@Override
|
||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
// set appropriate tableAlias for the exported id columns
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
String relativePrefix = ctx.relativePrefix(property.name());
|
||||
ctx.pushTableAlias(relativePrefix);
|
||||
property.targetIdBinder.appendSelect(ctx, subQuery);
|
||||
ctx.popTableAlias();
|
||||
@@ -30,7 +30,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
||||
|
||||
@Override
|
||||
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
String relativePrefix = ctx.relativePrefix(property.name());
|
||||
if (softDelete && !ctx.isIncludeSoftDelete()) {
|
||||
property.tableJoin.addJoin(joinType, relativePrefix, ctx, softDeletePredicate);
|
||||
} else {
|
||||
|
||||
@@ -63,7 +63,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
|
||||
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
// add join to support the discriminator column
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name);
|
||||
String relativePrefix = ctx.relativePrefix(property.name);
|
||||
ctx.addExtraJoin(new Extra(relativePrefix, joinType));
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
if (!subQuery) {
|
||||
// add discriminator column
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
String tableAlias = ctx.getTableAlias(relativePrefix);
|
||||
String relativePrefix = ctx.relativePrefix(property.name());
|
||||
String tableAlias = ctx.tableAlias(relativePrefix);
|
||||
ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn());
|
||||
}
|
||||
property.importedId.sqlAppend(ctx);
|
||||
|
||||
@@ -455,7 +455,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
if (formula && sqlFormulaJoin != null) {
|
||||
ctx.appendFormulaJoin(sqlFormulaJoin, joinType, manyWhere);
|
||||
} else if (secondaryTableJoin != null) {
|
||||
String relativePrefix = ctx.getRelativePrefix(secondaryTableJoinPrefix);
|
||||
String relativePrefix = ctx.relativePrefix(secondaryTableJoinPrefix);
|
||||
secondaryTableJoin.addJoin(joinType, relativePrefix, ctx);
|
||||
}
|
||||
}
|
||||
@@ -481,7 +481,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
ctx.appendFormulaSelect(sqlFormulaSelect);
|
||||
} else if (!isTransient && !ignoreDraftOnlyProperty(ctx.isDraftQuery())) {
|
||||
if (secondaryTableJoin != null) {
|
||||
ctx.pushTableAlias(ctx.getRelativePrefix(secondaryTableJoinPrefix));
|
||||
ctx.pushTableAlias(ctx.relativePrefix(secondaryTableJoinPrefix));
|
||||
}
|
||||
if (dbEncrypted) {
|
||||
ctx.appendRawColumn(decryptSqlWithColumnAlias(ctx.peekTableAlias()));
|
||||
|
||||
@@ -326,7 +326,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
*/
|
||||
@Override
|
||||
public void lazyLoadMany(EntityBean current) {
|
||||
EntityBean parentBean = childMasterProperty.getValueAsEntityBean(current);
|
||||
EntityBean parentBean = childMasterProperty.valueAsEntityBean(current);
|
||||
if (parentBean != null) {
|
||||
addBeanToCollectionWithCreate(parentBean, current, true);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
* Return the property value as an entity bean.
|
||||
*/
|
||||
@Override
|
||||
public EntityBean getValueAsEntityBean(EntityBean owner) {
|
||||
public EntityBean valueAsEntityBean(EntityBean owner) {
|
||||
return (EntityBean) getValue(owner);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface DbSqlContext {
|
||||
/**
|
||||
* Return a list of encrypted properties which require additional binding.
|
||||
*/
|
||||
BeanProperty[] getEncryptedProps();
|
||||
BeanProperty[] encryptedProps();
|
||||
|
||||
/**
|
||||
* Append a string directly to the SQL buffer.
|
||||
@@ -83,7 +83,7 @@ public interface DbSqlContext {
|
||||
/**
|
||||
* Return the current context of the sql context.
|
||||
*/
|
||||
String getContent();
|
||||
String content();
|
||||
|
||||
/**
|
||||
* Push a join node onto the stack.
|
||||
@@ -99,14 +99,14 @@ public interface DbSqlContext {
|
||||
* Return a table alias without many where clause joins. Typically this is for
|
||||
* the select clause (fetch joins).
|
||||
*/
|
||||
String getTableAlias(String prefix);
|
||||
String tableAlias(String prefix);
|
||||
|
||||
/**
|
||||
* Return a table alias that takes into account many where joins.
|
||||
*/
|
||||
String getTableAliasManyWhere(String prefix);
|
||||
String tableAliasManyWhere(String prefix);
|
||||
|
||||
String getRelativePrefix(String propName);
|
||||
String relativePrefix(String propName);
|
||||
|
||||
/**
|
||||
* Append the lower and upper bound columns into the select clause
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class TableJoin {
|
||||
private final int queryHash;
|
||||
|
||||
private final PropertyForeignKey foreignKey;
|
||||
|
||||
|
||||
private final String extraWhere;
|
||||
|
||||
public TableJoin(DeployTableJoin deploy) {
|
||||
@@ -135,21 +135,21 @@ public final class TableJoin {
|
||||
|
||||
public void addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx, String predicate) {
|
||||
String[] names = SplitName.split(prefix);
|
||||
String a1 = ctx.getTableAlias(names[0]);
|
||||
String a2 = ctx.getTableAlias(prefix);
|
||||
String a1 = ctx.tableAlias(names[0]);
|
||||
String a2 = ctx.tableAlias(prefix);
|
||||
addJoin(joinType, a1, a2, ctx);
|
||||
ctx.append(" and ").append(a2).append(predicate);
|
||||
}
|
||||
|
||||
public SqlJoinType addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx) {
|
||||
String[] names = SplitName.split(prefix);
|
||||
String a1 = ctx.getTableAlias(names[0]);
|
||||
String a2 = ctx.getTableAlias(prefix);
|
||||
String a1 = ctx.tableAlias(names[0]);
|
||||
String a2 = ctx.tableAlias(prefix);
|
||||
return addJoin(joinType, a1, a2, ctx);
|
||||
}
|
||||
|
||||
public SqlJoinType addJoin(SqlJoinType joinType, String a1, String a2, DbSqlContext ctx) {
|
||||
String joinLiteral = joinType.getLiteral(type);
|
||||
String joinLiteral = joinType.literal(type);
|
||||
ctx.addJoin(joinLiteral, table, columns(), a1, a2, extraWhere);
|
||||
return joinType.autoToOuter(type);
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
|
||||
@Override
|
||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||
CQuery<?> subQuery = compileSubQuery(request);
|
||||
this.bindParams = subQuery.predicates().getWhereExprBindValues();
|
||||
this.bindParams = subQuery.predicates().whereExprBindValues();
|
||||
this.sql = subQuery.generatedSql().replace('\n', ' ');
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ final class InQueryExpression extends AbstractExpression implements UnsupportedD
|
||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||
|
||||
CQuery<?> subQuery = compileSubQuery(request);
|
||||
this.bindParams = subQuery.predicates().getWhereExprBindValues();
|
||||
this.bindParams = subQuery.predicates().whereExprBindValues();
|
||||
this.sql = subQuery.generatedSql().replace('\n', ' ');
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import io.ebeaninternal.server.deploy.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -867,7 +866,7 @@ public final class DefaultPersister implements Persister {
|
||||
for (BeanPropertyAssocOne<?> prop : desc.propertiesOneExportedSave()) {
|
||||
// check for partial beans
|
||||
if (request.isLoadedProperty(prop)) {
|
||||
EntityBean detailBean = prop.getValueAsEntityBean(parentBean);
|
||||
EntityBean detailBean = prop.valueAsEntityBean(parentBean);
|
||||
if (detailBean != null) {
|
||||
if (!prop.isSaveRecurseSkippable(detailBean)) {
|
||||
t.depth(+1);
|
||||
@@ -1056,7 +1055,7 @@ public final class DefaultPersister implements Persister {
|
||||
request.setImportedOrphanForRemoval(prop);
|
||||
}
|
||||
if (request.isLoadedProperty(prop)) {
|
||||
EntityBean detailBean = prop.getValueAsEntityBean(request.entityBean());
|
||||
EntityBean detailBean = prop.valueAsEntityBean(request.entityBean());
|
||||
if (detailBean != null
|
||||
&& !prop.isSaveRecurseSkippable(detailBean)
|
||||
&& !prop.isReference(detailBean)
|
||||
|
||||
@@ -190,8 +190,8 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
// so its available to the user...
|
||||
query.setGeneratedSql(queryPlan.sql());
|
||||
SqlTreePlan sqlTree = queryPlan.sqlTree();
|
||||
this.rootNode = sqlTree.getRootNode();
|
||||
this.manyProperty = sqlTree.getManyProperty();
|
||||
this.rootNode = sqlTree.rootNode();
|
||||
this.manyProperty = sqlTree.manyProperty();
|
||||
this.sql = queryPlan.sql();
|
||||
this.rawSql = queryPlan.isRawSql();
|
||||
this.logWhereSql = queryPlan.logWhereSql();
|
||||
|
||||
@@ -62,14 +62,14 @@ final class CQueryBindCapture implements SpiQueryBindCapture {
|
||||
* Collect the query plan using already captured bind values.
|
||||
*/
|
||||
public boolean collectQueryPlan(CQueryPlanRequest request) {
|
||||
if (bindCapture == null || request.getSince() < lastBindCapture) {
|
||||
if (bindCapture == null || request.since() < lastBindCapture) {
|
||||
// no bind capture since the last capture
|
||||
return false;
|
||||
}
|
||||
|
||||
final BindCapture last = this.bindCapture;
|
||||
|
||||
SpiDbQueryPlan queryPlan = manager.collectPlan(request.getConnection(), this.queryPlan, last);
|
||||
SpiDbQueryPlan queryPlan = manager.collectPlan(request.connection(), this.queryPlan, last);
|
||||
if (queryPlan != null) {
|
||||
request.add(queryPlan.with(queryTimeMicros, captureCount));
|
||||
// effectively turn off bind capture for this plan
|
||||
|
||||
@@ -110,7 +110,7 @@ final class CQueryBuilder {
|
||||
sql = buildUpdateSql(request, rootTableAlias, predicates, sqlTree);
|
||||
}
|
||||
// cache the query plan
|
||||
queryPlan = new CQueryPlan(request, sql, sqlTree.plan(), predicates.getLogWhereSql());
|
||||
queryPlan = new CQueryPlan(request, sql, sqlTree.plan(), predicates.logWhereSql());
|
||||
request.putQueryPlan(queryPlan);
|
||||
return new CQueryUpdate(request, predicates, queryPlan);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ final class CQueryBuilder {
|
||||
if (rootTableAlias != null) {
|
||||
sb.append(" ").append(rootTableAlias);
|
||||
}
|
||||
sb.append(" set ").append(predicates.getDbUpdateClause());
|
||||
sb.append(" set ").append(predicates.dbUpdateClause());
|
||||
String updateClause = sb.toString();
|
||||
if (sqlTree.noJoins() && request.isInlineSqlUpdateLimit()) {
|
||||
// simple - update table set ... where ...
|
||||
@@ -196,7 +196,7 @@ final class CQueryBuilder {
|
||||
SqlTree sqlTree = createSqlTree(request, predicates);
|
||||
SqlLimitResponse s = buildSql(null, request, predicates, sqlTree);
|
||||
|
||||
queryPlan = new CQueryPlan(request, s.getSql(), sqlTree.plan(), predicates.getLogWhereSql());
|
||||
queryPlan = new CQueryPlan(request, s.getSql(), sqlTree.plan(), predicates.logWhereSql());
|
||||
request.putQueryPlan(queryPlan);
|
||||
return new CQueryFetchSingleAttribute(request, predicates, queryPlan, query.isCountDistinct());
|
||||
}
|
||||
@@ -217,14 +217,14 @@ final class CQueryBuilder {
|
||||
/**
|
||||
* Return the history support if this query needs it (is a 'as of' type query).
|
||||
*/
|
||||
<T> CQueryHistorySupport getHistorySupport(SpiQuery<T> query) {
|
||||
<T> CQueryHistorySupport historySupport(SpiQuery<T> query) {
|
||||
return query.getTemporalMode().isHistory() ? historySupport : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the draft support (or null) for a 'asDraft' query.
|
||||
*/
|
||||
<T> CQueryDraftSupport getDraftSupport(SpiQuery<T> query) {
|
||||
<T> CQueryDraftSupport draftSupport(SpiQuery<T> query) {
|
||||
return query.getTemporalMode() == SpiQuery.TemporalMode.DRAFT ? draftSupport : null;
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ final class CQueryBuilder {
|
||||
}
|
||||
}
|
||||
// cache the query plan
|
||||
queryPlan = new CQueryPlan(request, sql, sqlTree.plan(), predicates.getLogWhereSql());
|
||||
queryPlan = new CQueryPlan(request, sql, sqlTree.plan(), predicates.logWhereSql());
|
||||
request.putQueryPlan(queryPlan);
|
||||
return new CQueryRowCount(queryPlan, request, predicates);
|
||||
}
|
||||
@@ -340,9 +340,9 @@ final class CQueryBuilder {
|
||||
SqlLimitResponse res = buildSql(null, request, predicates, sqlTree);
|
||||
boolean rawSql = request.isRawSql();
|
||||
if (rawSql) {
|
||||
queryPlan = new CQueryPlanRawSql(request, res, sqlTree, predicates.getLogWhereSql());
|
||||
queryPlan = new CQueryPlanRawSql(request, res, sqlTree, predicates.logWhereSql());
|
||||
} else {
|
||||
queryPlan = new CQueryPlan(request, res, sqlTree.plan(), false, predicates.getLogWhereSql());
|
||||
queryPlan = new CQueryPlan(request, res, sqlTree.plan(), false, predicates.logWhereSql());
|
||||
}
|
||||
BeanDescriptor<T> desc = request.descriptor();
|
||||
if (desc.isReadAuditing()) {
|
||||
@@ -552,7 +552,7 @@ final class CQueryBuilder {
|
||||
this.select = select;
|
||||
this.updateStatement = updateStatement;
|
||||
this.distinct = query.isDistinct() || select.isSqlDistinct();
|
||||
this.dbOrderBy = predicates.getDbOrderBy();
|
||||
this.dbOrderBy = predicates.dbOrderBy();
|
||||
this.countSingleAttribute = query.isCountDistinct() && query.isSingleAttribute();
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ final class CQueryBuilder {
|
||||
if (selectClause != null) {
|
||||
sb.append(selectClause);
|
||||
} else {
|
||||
useSqlLimiter = (query.hasMaxRowsOrFirstRow() && (select.getManyProperty() == null || query.isSingleAttribute()));
|
||||
useSqlLimiter = (query.hasMaxRowsOrFirstRow() && (select.manyProperty() == null || query.isSingleAttribute()));
|
||||
if (!useSqlLimiter) {
|
||||
appendSelectDistinct();
|
||||
}
|
||||
@@ -578,9 +578,9 @@ final class CQueryBuilder {
|
||||
sb.append("t0.").append(idProp.dbColumn()).append(", ");
|
||||
}
|
||||
}
|
||||
sb.append(select.getSelectSql()).append(" as attribute_");
|
||||
sb.append(select.selectSql()).append(" as attribute_");
|
||||
} else {
|
||||
sb.append(select.getSelectSql());
|
||||
sb.append(select.selectSql());
|
||||
}
|
||||
if (request.isInlineCountDistinct()) {
|
||||
sb.append(")");
|
||||
@@ -590,7 +590,7 @@ final class CQueryBuilder {
|
||||
final OrderBy<?> orderBy = query.getOrderBy();
|
||||
if (orderBy != null && orderBy.supportsSelect()) {
|
||||
String trimmed = DbOrderByTrim.trim(dbOrderBy);
|
||||
if (query.isSingleAttribute() && select.getSelectSql().startsWith(trimmed)) {
|
||||
if (query.isSingleAttribute() && select.selectSql().startsWith(trimmed)) {
|
||||
// NOP, already in SQL
|
||||
// TODO: what to do if we select("id").orderBy("prop,id")?
|
||||
// Can we live with a query like "select t0.id, t0.prop, t0.id from"
|
||||
@@ -610,7 +610,7 @@ final class CQueryBuilder {
|
||||
sb.append("count(");
|
||||
}
|
||||
sb.append("distinct ");
|
||||
String distinctOn = select.getDistinctOn();
|
||||
String distinctOn = select.distinctOn();
|
||||
if (distinctOn != null) {
|
||||
sb.append("on (").append(distinctOn).append(") ");
|
||||
}
|
||||
@@ -620,7 +620,7 @@ final class CQueryBuilder {
|
||||
private void appendFrom() {
|
||||
if (selectClause == null || !selectClause.startsWith("update")) {
|
||||
sb.append(" from ");
|
||||
sb.append(select.getFromSql());
|
||||
sb.append(select.fromSql());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ final class CQueryBuilder {
|
||||
}
|
||||
|
||||
private void appendInheritanceWhere() {
|
||||
String inheritanceWhere = select.getInheritanceWhereSql();
|
||||
String inheritanceWhere = select.inheritanceWhereSql();
|
||||
if (!inheritanceWhere.isEmpty()) {
|
||||
sb.append(" where");
|
||||
sb.append(inheritanceWhere);
|
||||
@@ -647,7 +647,7 @@ final class CQueryBuilder {
|
||||
query.incrementAsOfTableCount();
|
||||
if (!historySupport.isStandardsBased()){
|
||||
appendAndOrWhere();
|
||||
sb.append(historySupport.getAsOfPredicate(request.baseTableAlias()));
|
||||
sb.append(historySupport.asOfPredicate(request.baseTableAlias()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -696,16 +696,16 @@ final class CQueryBuilder {
|
||||
appendInheritanceWhere();
|
||||
appendHistoryAsOfPredicate();
|
||||
appendFindId();
|
||||
appendToWhere(predicates.getDbWhere());
|
||||
appendToWhere(predicates.getDbFilterMany());
|
||||
appendToWhere(predicates.dbWhere());
|
||||
appendToWhere(predicates.dbFilterMany());
|
||||
if (!query.isIncludeSoftDeletes()) {
|
||||
appendSoftDelete();
|
||||
}
|
||||
String groupBy = select.getGroupBy();
|
||||
String groupBy = select.groupBy();
|
||||
if (groupBy != null) {
|
||||
sb.append(" group by ").append(groupBy);
|
||||
}
|
||||
String dbHaving = predicates.getDbHaving();
|
||||
String dbHaving = predicates.dbHaving();
|
||||
if (hasValue(dbHaving)) {
|
||||
sb.append(" having ").append(dbHaving);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,10 @@ final class CQueryBuilderRawSql {
|
||||
* Build the full SQL Select statement for the request.
|
||||
*/
|
||||
SqlLimitResponse buildSql(OrmQueryRequest<?> request, CQueryPredicates predicates, SpiRawSql.Sql rsql) {
|
||||
|
||||
if (rsql == null) {
|
||||
// this is a ResultSet based RawSql query - just use some placeholder for the SQL
|
||||
return new SqlLimitResponse(CQueryPlan.RESULT_SET_BASED_RAW_SQL);
|
||||
}
|
||||
|
||||
if (!rsql.isParsed()) {
|
||||
String sql = rsql.getUnparsedSql();
|
||||
BindParams bindParams = request.query().getBindParams();
|
||||
@@ -41,16 +39,13 @@ final class CQueryBuilderRawSql {
|
||||
return new SqlLimitResponse(sql);
|
||||
}
|
||||
|
||||
String orderBy = getOrderBy(predicates, rsql);
|
||||
|
||||
String orderBy = orderBy(predicates, rsql);
|
||||
// build the actual sql String
|
||||
String sql = buildMainQuery(orderBy, request, predicates, rsql);
|
||||
|
||||
SpiQuery<?> query = request.query();
|
||||
if (query.hasMaxRowsOrFirstRow() && sqlLimiter != null) {
|
||||
// wrap with a limit offset or ROW_NUMBER() etc
|
||||
return sqlLimiter.limit(new OrmQueryLimitRequest(sql, orderBy, query, dbPlatform, rsql.isDistinct() || query.isDistinct()));
|
||||
|
||||
} else {
|
||||
// add back select keyword (it was removed to support sqlQueryLimiter)
|
||||
String prefix = "select " + (rsql.isDistinct() ? "distinct " : "");
|
||||
@@ -86,7 +81,7 @@ final class CQueryBuilderRawSql {
|
||||
dynamicWhere = descriptor.idBinderIdSql(null);
|
||||
}
|
||||
|
||||
String dbWhere = predicates.getDbWhere();
|
||||
String dbWhere = predicates.dbWhere();
|
||||
if (hasValue(dbWhere)) {
|
||||
if (dynamicWhere == null) {
|
||||
dynamicWhere = dbWhere;
|
||||
@@ -109,7 +104,7 @@ final class CQueryBuilderRawSql {
|
||||
sb.append(preHaving).append(" ");
|
||||
}
|
||||
|
||||
String dbHaving = predicates.getDbHaving();
|
||||
String dbHaving = predicates.dbHaving();
|
||||
if (hasValue(dbHaving)) {
|
||||
if (sql.isAndHavingExpr()) {
|
||||
sb.append(" and ");
|
||||
@@ -128,8 +123,8 @@ final class CQueryBuilderRawSql {
|
||||
return s != null && !s.isEmpty();
|
||||
}
|
||||
|
||||
private String getOrderBy(CQueryPredicates predicates, SpiRawSql.Sql sql) {
|
||||
String orderBy = predicates.getDbOrderBy();
|
||||
private String orderBy(CQueryPredicates predicates, SpiRawSql.Sql sql) {
|
||||
String orderBy = predicates.dbOrderBy();
|
||||
if (orderBy != null) {
|
||||
return orderBy;
|
||||
} else {
|
||||
|
||||
@@ -22,7 +22,7 @@ final class CQueryDraftSupport {
|
||||
* This returns null for entities that are not draftable and in that case
|
||||
* the usual base table is used.
|
||||
*/
|
||||
String getDraftTable(String table) {
|
||||
String draftTable(String table) {
|
||||
return tableMap.get(table);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ public final class CQueryEngine {
|
||||
try {
|
||||
int rows = query.execute();
|
||||
if (request.logSql()) {
|
||||
request.logSql(Str.add(query.getGeneratedSql(), "; --bind(", query.getBindLog(), ") --micros(", query.micros() + ") --rows(", rows + ")"));
|
||||
request.logSql(Str.add(query.generatedSql(), "; --bind(", query.bindLog(), ") --micros(", query.micros() + ") --rows(", rows + ")"));
|
||||
}
|
||||
return rows;
|
||||
} catch (SQLException e) {
|
||||
throw translate(request, query.getBindLog(), query.getGeneratedSql(), e);
|
||||
throw translate(request, query.bindLog(), query.generatedSql(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,13 +98,13 @@ public final class CQueryEngine {
|
||||
try {
|
||||
rcQuery.findCollection(collection);
|
||||
if (request.logSql()) {
|
||||
logGeneratedSql(request, rcQuery.getGeneratedSql(), rcQuery.getBindLog(), rcQuery.micros());
|
||||
logGeneratedSql(request, rcQuery.generatedSql(), rcQuery.bindLog(), rcQuery.micros());
|
||||
}
|
||||
if (request.logSummary()) {
|
||||
request.transaction().logSummary(rcQuery.getSummary());
|
||||
request.transaction().logSummary(rcQuery.summary());
|
||||
}
|
||||
if (request.isQueryCachePut()) {
|
||||
request.addDependentTables(rcQuery.getDependentTables());
|
||||
request.addDependentTables(rcQuery.dependentTables());
|
||||
if (collection instanceof List) {
|
||||
collection = (A) Collections.unmodifiableList((List<?>) collection);
|
||||
request.putToQueryCache(collection);
|
||||
@@ -121,7 +121,7 @@ public final class CQueryEngine {
|
||||
}
|
||||
return collection;
|
||||
} catch (SQLException e) {
|
||||
throw translate(request, rcQuery.getBindLog(), rcQuery.getGeneratedSql(), e);
|
||||
throw translate(request, rcQuery.bindLog(), rcQuery.generatedSql(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,21 +164,21 @@ public final class CQueryEngine {
|
||||
try {
|
||||
int count = rcQuery.findCount();
|
||||
if (request.logSql()) {
|
||||
logGeneratedSql(request, rcQuery.getGeneratedSql(), rcQuery.getBindLog(), rcQuery.micros());
|
||||
logGeneratedSql(request, rcQuery.generatedSql(), rcQuery.bindLog(), rcQuery.micros());
|
||||
}
|
||||
if (request.logSummary()) {
|
||||
request.transaction().logSummary(rcQuery.getSummary());
|
||||
request.transaction().logSummary(rcQuery.summary());
|
||||
}
|
||||
if (request.query().isFutureFetch()) {
|
||||
request.transaction().end();
|
||||
}
|
||||
if (request.isQueryCachePut()) {
|
||||
request.addDependentTables(rcQuery.getDependentTables());
|
||||
request.addDependentTables(rcQuery.dependentTables());
|
||||
request.putToQueryCache(count);
|
||||
}
|
||||
return count;
|
||||
} catch (SQLException e) {
|
||||
throw translate(request, rcQuery.getBindLog(), rcQuery.getGeneratedSql(), e);
|
||||
throw translate(request, rcQuery.bindLog(), rcQuery.generatedSql(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,9 +271,7 @@ public final class CQueryEngine {
|
||||
} catch (SQLException e) {
|
||||
throw cquery.createPersistenceException(e);
|
||||
} finally {
|
||||
if (cquery != null) {
|
||||
cquery.close();
|
||||
}
|
||||
cquery.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,11 +297,11 @@ public final class CQueryEngine {
|
||||
}
|
||||
|
||||
private <T> String getSysPeriodLower(SpiQuery<T> query) {
|
||||
return historySupport.getSysPeriodLower(query.getAlias(T0));
|
||||
return historySupport.sysPeriodLower(query.getAlias(T0));
|
||||
}
|
||||
|
||||
private <T> String getSysPeriodUpper(SpiQuery<T> query) {
|
||||
return historySupport.getSysPeriodUpper(query.getAlias(T0));
|
||||
return historySupport.sysPeriodUpper(query.getAlias(T0));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,9 +371,7 @@ public final class CQueryEngine {
|
||||
} catch (SQLException e) {
|
||||
throw cquery.createPersistenceException(e);
|
||||
} finally {
|
||||
if (cquery != null) {
|
||||
cquery.close();
|
||||
}
|
||||
cquery.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-9
@@ -58,12 +58,12 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
/**
|
||||
* Return a summary description of this query.
|
||||
*/
|
||||
String getSummary() {
|
||||
String summary() {
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
sb.append("FindAttr exeMicros[").append(executionTimeMicros)
|
||||
.append("] rows[").append(rowCount)
|
||||
.append("] type[").append(desc.name())
|
||||
.append("] predicates[").append(predicates.getLogWhereSql())
|
||||
.append("] predicates[").append(predicates.logWhereSql())
|
||||
.append("] bind[").append(bindLog).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -75,6 +75,7 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
/**
|
||||
* Execute the query returning the row count.
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
void findCollection(Collection result) throws SQLException {
|
||||
long startNano = System.nanoTime();
|
||||
try {
|
||||
@@ -92,27 +93,27 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
if (queryPlan.executionTime(executionTimeMicros)) {
|
||||
queryPlan.captureBindForQueryPlan(predicates, executionTimeMicros);
|
||||
}
|
||||
getTransaction().profileEvent(this);
|
||||
transaction().profileEvent(this);
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
private SpiTransaction getTransaction() {
|
||||
private SpiTransaction transaction() {
|
||||
return request.transaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bind log.
|
||||
*/
|
||||
String getBindLog() {
|
||||
String bindLog() {
|
||||
return bindLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the generated sql.
|
||||
*/
|
||||
String getGeneratedSql() {
|
||||
String generatedSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
lock.lock();
|
||||
try {
|
||||
query.checkCancelled();
|
||||
SpiTransaction t = getTransaction();
|
||||
SpiTransaction t = transaction();
|
||||
profileOffset = t.profileOffset();
|
||||
Connection conn = t.getInternalConnection();
|
||||
pstmt = conn.prepareStatement(sql);
|
||||
@@ -160,12 +161,12 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
|
||||
@Override
|
||||
public void profile() {
|
||||
getTransaction()
|
||||
transaction()
|
||||
.profileStream()
|
||||
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), rowCount, query.getProfileId());
|
||||
}
|
||||
|
||||
Set<String> getDependentTables() {
|
||||
Set<String> dependentTables() {
|
||||
return queryPlan.dependentTables();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,30 +40,28 @@ final class CQueryHistorySupport {
|
||||
/**
|
||||
* Return the 'as of' history view for the given base table.
|
||||
*/
|
||||
String getAsOfView(String table) {
|
||||
String asOfView(String table) {
|
||||
return asOfTableMap.get(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the lower bound column.
|
||||
*/
|
||||
String getSysPeriodLower(String tableAlias) {
|
||||
String sysPeriodLower(String tableAlias) {
|
||||
return dbHistorySupport.getSysPeriodLower(tableAlias, sysPeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the upper bound column.
|
||||
*/
|
||||
String getSysPeriodUpper(String tableAlias) {
|
||||
String sysPeriodUpper(String tableAlias) {
|
||||
return dbHistorySupport.getSysPeriodUpper(tableAlias, sysPeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the predicate appended to the end of the query.
|
||||
* <p>
|
||||
* Note used for Oracle total recall etc with the more standard approach.
|
||||
*/
|
||||
String getAsOfPredicate(String tableAlias) {
|
||||
String asOfPredicate(String tableAlias) {
|
||||
return dbHistorySupport.getAsOfPredicate(tableAlias, sysPeriod);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@ import java.sql.SQLException;
|
||||
final class CQueryIteratorSimple<T> implements QueryIterator<T> {
|
||||
|
||||
private final CQuery<T> cquery;
|
||||
|
||||
private final OrmQueryRequest<T> request;
|
||||
|
||||
private boolean closed;
|
||||
|
||||
CQueryIteratorSimple(CQuery<T> cquery, OrmQueryRequest<T> request) {
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
final class CQueryOrderBy {
|
||||
|
||||
private final BeanDescriptor<?> desc;
|
||||
|
||||
private final OrderBy<?> orderBy;
|
||||
|
||||
/**
|
||||
@@ -32,9 +31,7 @@ final class CQueryOrderBy {
|
||||
}
|
||||
|
||||
private String parseInternal() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<Property> properties = orderBy.getProperties();
|
||||
if (properties.isEmpty()) {
|
||||
// order by clause removed by filterMany()
|
||||
@@ -52,7 +49,6 @@ final class CQueryOrderBy {
|
||||
}
|
||||
|
||||
private String parseProperty(Property p) {
|
||||
|
||||
String propName = p.getProperty();
|
||||
ElPropertyValue el = desc.elGetValue(propName);
|
||||
if (el == null) {
|
||||
@@ -65,7 +61,6 @@ final class CQueryOrderBy {
|
||||
IdBinder idBinder = ap.targetDescriptor().idBinder();
|
||||
return idBinder.getOrderBy(el.elName(), p.isAscending());
|
||||
}
|
||||
|
||||
return p.toStringFormat();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
this.sqlTree = sqlTree;
|
||||
this.rawSql = rawSql;
|
||||
this.logWhereSql = logWhereSql;
|
||||
this.encryptedProps = sqlTree.getEncryptedProps();
|
||||
this.encryptedProps = sqlTree.encryptedProps();
|
||||
this.stats = new CQueryPlanStats(this);
|
||||
this.dependentTables = sqlTree.dependentTables();
|
||||
this.bindCapture = initBindCapture(query);
|
||||
@@ -117,7 +117,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
this.sqlTree = sqlTree;
|
||||
this.rawSql = false;
|
||||
this.logWhereSql = logWhereSql;
|
||||
this.encryptedProps = sqlTree.getEncryptedProps();
|
||||
this.encryptedProps = sqlTree.encryptedProps();
|
||||
this.stats = new CQueryPlanStats(this);
|
||||
this.dependentTables = sqlTree.dependentTables();
|
||||
this.bindCapture = initBindCaptureRaw(sql, query);
|
||||
@@ -247,7 +247,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
|
||||
private String calcAuditQueryKey() {
|
||||
// rawSql needs to include the MD5 hash of the sql
|
||||
return rawSql ? planKey.getPartialKey() + "_" + hash : planKey.getPartialKey();
|
||||
return rawSql ? planKey.partialKey() + "_" + hash : planKey.partialKey();
|
||||
}
|
||||
|
||||
final SqlTreePlan sqlTree() {
|
||||
@@ -288,11 +288,11 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
* Return the time this query plan was last used.
|
||||
*/
|
||||
public final long lastQueryTime() {
|
||||
return stats.getLastQueryTime();
|
||||
return stats.lastQueryTime();
|
||||
}
|
||||
|
||||
final ScalarDataReader<?> singleAttributeScalarType() {
|
||||
return sqlTree.getRootNode().getSingleAttributeReader();
|
||||
return sqlTree.rootNode().singleAttributeReader();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class CQueryPlanManager implements QueryPlanManager {
|
||||
while (req.hasNext()) {
|
||||
req.nextCapture();
|
||||
}
|
||||
return req.getPlans();
|
||||
return req.plans();
|
||||
} catch (SQLException e) {
|
||||
CoreLog.log.error("Error during query plan collection", e);
|
||||
return emptyList();
|
||||
|
||||
@@ -34,7 +34,7 @@ final class CQueryPlanRequest {
|
||||
/**
|
||||
* Return the connection used to collect the db query plan.
|
||||
*/
|
||||
Connection getConnection() {
|
||||
Connection connection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ final class CQueryPlanRequest {
|
||||
/**
|
||||
* Return the min epoch time in millis for minimum bind capture age.
|
||||
*/
|
||||
long getSince() {
|
||||
long since() {
|
||||
return since;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the captured query plans.
|
||||
*/
|
||||
List<MetaQueryPlan> getPlans() {
|
||||
List<MetaQueryPlan> plans() {
|
||||
return plans;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public final class CQueryPlanStats {
|
||||
/**
|
||||
* Return the last time this query was executed.
|
||||
*/
|
||||
long getLastQueryTime() {
|
||||
long lastQueryTime() {
|
||||
return lastQueryTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -350,60 +350,60 @@ public final class CQueryPredicates {
|
||||
/**
|
||||
* Return the bind values for the where expression.
|
||||
*/
|
||||
public List<Object> getWhereExprBindValues() {
|
||||
public List<Object> whereExprBindValues() {
|
||||
return where == null ? Collections.emptyList() : where.getBindValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the db update set clause for an UpdateQuery.
|
||||
*/
|
||||
String getDbUpdateClause() {
|
||||
String dbUpdateClause() {
|
||||
return dbUpdateClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the db column version of the combined where clause.
|
||||
*/
|
||||
String getDbHaving() {
|
||||
String dbHaving() {
|
||||
return dbHaving;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the db column version of the combined where clause.
|
||||
*/
|
||||
String getDbWhere() {
|
||||
String dbWhere() {
|
||||
return dbWhere;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a db filter for filtering many fetch joins.
|
||||
*/
|
||||
String getDbFilterMany() {
|
||||
String dbFilterMany() {
|
||||
return dbFilterMany;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the db column version of the order by clause.
|
||||
*/
|
||||
String getDbOrderBy() {
|
||||
String dbOrderBy() {
|
||||
return dbOrderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the includes required for the where and order by clause.
|
||||
*/
|
||||
Set<String> getPredicateIncludes() {
|
||||
Set<String> predicateIncludes() {
|
||||
return predicateIncludes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the orderBy includes.
|
||||
*/
|
||||
Set<String> getOrderByIncludes() {
|
||||
Set<String> orderByIncludes() {
|
||||
return orderByIncludes;
|
||||
}
|
||||
|
||||
String getLogWhereSql() {
|
||||
String logWhereSql() {
|
||||
if (dbWhere == null && dbFilterMany == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
/**
|
||||
* Return a summary description of this query.
|
||||
*/
|
||||
public String getSummary() {
|
||||
public String summary() {
|
||||
//noinspection StringBufferReplaceableByString
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
sb.append("FindCount exeMicros[").append(executionTimeMicros)
|
||||
.append("] rows[").append(rowCount)
|
||||
.append("] type[").append(desc.fullName())
|
||||
.append("] predicates[").append(predicates.getLogWhereSql())
|
||||
.append("] predicates[").append(predicates.logWhereSql())
|
||||
.append("] bind[").append(bindLog).append("]");
|
||||
|
||||
return sb.toString();
|
||||
@@ -66,14 +66,14 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
/**
|
||||
* Return the bind log.
|
||||
*/
|
||||
public String getBindLog() {
|
||||
public String bindLog() {
|
||||
return bindLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the generated sql.
|
||||
*/
|
||||
public String getGeneratedSql() {
|
||||
public String generatedSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
public int findCount() throws SQLException {
|
||||
long startNano = System.nanoTime();
|
||||
try {
|
||||
SpiTransaction t = getTransaction();
|
||||
SpiTransaction t = transaction();
|
||||
profileOffset = t.profileOffset();
|
||||
Connection conn = t.getInternalConnection();
|
||||
lock.lock();
|
||||
@@ -119,7 +119,7 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
}
|
||||
}
|
||||
|
||||
private SpiTransaction getTransaction() {
|
||||
private SpiTransaction transaction() {
|
||||
return request.transaction();
|
||||
}
|
||||
|
||||
@@ -135,12 +135,12 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
|
||||
@Override
|
||||
public void profile() {
|
||||
getTransaction()
|
||||
transaction()
|
||||
.profileStream()
|
||||
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), rowCount, query.getProfileId());
|
||||
}
|
||||
|
||||
Set<String> getDependentTables() {
|
||||
Set<String> dependentTables() {
|
||||
return queryPlan.dependentTables();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery
|
||||
/**
|
||||
* Return the bind log.
|
||||
*/
|
||||
public String getBindLog() {
|
||||
public String bindLog() {
|
||||
return bindLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the generated sql.
|
||||
*/
|
||||
public String getGeneratedSql() {
|
||||
public String generatedSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery
|
||||
public int execute() throws SQLException {
|
||||
long startNano = System.nanoTime();
|
||||
try {
|
||||
SpiTransaction t = getTransaction();
|
||||
SpiTransaction t = transaction();
|
||||
profileOffset = t.profileOffset();
|
||||
Connection conn = t.getInternalConnection();
|
||||
lock.lock();
|
||||
@@ -97,7 +97,7 @@ final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery
|
||||
return executionTimeMicros;
|
||||
}
|
||||
|
||||
private SpiTransaction getTransaction() {
|
||||
private SpiTransaction transaction() {
|
||||
return request.transaction();
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery
|
||||
|
||||
@Override
|
||||
public void profile() {
|
||||
getTransaction()
|
||||
transaction()
|
||||
.profileStream()
|
||||
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), rowCount, query.getProfileId());
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanProperty[] getEncryptedProps() {
|
||||
public BeanProperty[] encryptedProps() {
|
||||
if (encryptedProps == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -125,13 +125,13 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
sb.append(" ").append(type);
|
||||
boolean addAsOfOnClause = false;
|
||||
if (draftSupport != null) {
|
||||
appendTable(table, draftSupport.getDraftTable(table));
|
||||
appendTable(table, draftSupport.draftTable(table));
|
||||
} else if (!historyQuery) {
|
||||
sb.append(" ").append(table).append(" ");
|
||||
} else {
|
||||
// check if there is an associated history table and if so
|
||||
// use the unionAll view - we expect an additional predicate to match
|
||||
String asOfView = historySupport.getAsOfView(table);
|
||||
String asOfView = historySupport.asOfView(table);
|
||||
appendTable(table, asOfView);
|
||||
if (asOfView != null) {
|
||||
if (historySupport.isStandardsBased()) {
|
||||
@@ -161,7 +161,7 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
}
|
||||
}
|
||||
if (addAsOfOnClause) {
|
||||
sb.append(" and ").append(historySupport.getAsOfPredicate(a2));
|
||||
sb.append(" and ").append(historySupport.asOfPredicate(a2));
|
||||
asOfTableCount++;
|
||||
}
|
||||
if (extraWhere != null && !extraWhere.isEmpty()) {
|
||||
@@ -191,17 +191,17 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableAlias(String prefix) {
|
||||
return alias.getTableAlias(prefix);
|
||||
public String tableAlias(String prefix) {
|
||||
return alias.tableAlias(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableAliasManyWhere(String prefix) {
|
||||
return alias.getTableAliasManyWhere(prefix);
|
||||
public String tableAliasManyWhere(String prefix) {
|
||||
return alias.tableAliasManyWhere(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRelativePrefix(String propName) {
|
||||
public String relativePrefix(String propName) {
|
||||
return currentPrefix == null ? propName : currentPrefix + "." + propName;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
public void pushTableAlias(String prefix) {
|
||||
prefixStack.push(currentPrefix);
|
||||
currentPrefix = prefix;
|
||||
tableAliasStack.push(getTableAlias(prefix));
|
||||
tableAliasStack.push(tableAlias(prefix));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,7 +227,7 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
@Override
|
||||
public void appendFormulaJoin(String sqlFormulaJoin, SqlJoinType joinType, String manyWhere) {
|
||||
// replace ${ta} placeholder with the real table alias...
|
||||
String tableAlias = manyWhere == null ? tableAliasStack.peek() : getTableAliasManyWhere(manyWhere);
|
||||
String tableAlias = manyWhere == null ? tableAliasStack.peek() : tableAliasManyWhere(manyWhere);
|
||||
String converted = sqlFormulaJoin.replace(tableAliasPlaceHolder, tableAlias);
|
||||
if (formulaJoins == null) {
|
||||
formulaJoins = new HashSet<>();
|
||||
@@ -272,10 +272,10 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
public void appendHistorySysPeriod() {
|
||||
String tableAlias = tableAliasStack.peek();
|
||||
sb.append(COMMA);
|
||||
sb.append(historySupport.getSysPeriodLower(tableAlias));
|
||||
sb.append(historySupport.sysPeriodLower(tableAlias));
|
||||
appendColumnAlias();
|
||||
sb.append(COMMA);
|
||||
sb.append(historySupport.getSysPeriodUpper(tableAlias));
|
||||
sb.append(historySupport.sysPeriodUpper(tableAlias));
|
||||
appendColumnAlias();
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent() {
|
||||
public String content() {
|
||||
String s = sb.toString();
|
||||
sb = new StringBuilder(STRING_BUILDER_INITIAL_CAPACITY);
|
||||
return s;
|
||||
|
||||
@@ -48,9 +48,7 @@ import java.util.stream.Stream;
|
||||
final class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQueryFetch {
|
||||
|
||||
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 OrmQueryDetail detail = new OrmQueryDetail();
|
||||
|
||||
-3
@@ -26,11 +26,8 @@ import java.util.function.Predicate;
|
||||
public final class DefaultRelationalQueryEngine implements RelationalQueryEngine {
|
||||
|
||||
private final Binder binder;
|
||||
|
||||
private final String dbTrueValue;
|
||||
|
||||
private final boolean binaryOptimizedUUID;
|
||||
|
||||
private final TimedMetricMap timedMetricMap;
|
||||
|
||||
public DefaultRelationalQueryEngine(Binder binder, String dbTrueValue, boolean binaryOptimizedUUID) {
|
||||
|
||||
@@ -10,7 +10,7 @@ public final class ExtraJoin {
|
||||
this.containsMany = containsMany;
|
||||
}
|
||||
|
||||
public STreePropertyAssoc getProperty() {
|
||||
public STreePropertyAssoc property() {
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,19 +15,13 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
public final class LimitOffsetPagedList<T> implements PagedList<T> {
|
||||
|
||||
private final transient SpiEbeanServer server;
|
||||
|
||||
private final transient ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
private final SpiQuery<T> query;
|
||||
|
||||
private final int firstRow;
|
||||
|
||||
private final int maxRows;
|
||||
|
||||
private int foregroundTotalRowCount = -1;
|
||||
|
||||
private Future<Integer> futureRowCount;
|
||||
|
||||
private List<T> list;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ public class NativeSqlQueryPlanKey implements CQueryPlanKey {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getPartialKey();
|
||||
return partialKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,7 +29,7 @@ public class NativeSqlQueryPlanKey implements CQueryPlanKey {
|
||||
* can be used as a short form proxy for the actual sql.
|
||||
*/
|
||||
@Override
|
||||
public String getPartialKey() {
|
||||
public String partialKey() {
|
||||
return hashCode() + "_n";
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ final class OrderVersionDesc implements Comparator<Version<?>>, Serializable {
|
||||
|
||||
@Override
|
||||
public int compare(Version<?> o1, Version<?> o2) {
|
||||
|
||||
Timestamp v1 = o1.getStart();
|
||||
if (v1 == null) {
|
||||
return 1;
|
||||
|
||||
@@ -19,11 +19,11 @@ public final class QueryFutureIds<T> extends BaseFuture<List<Object>> implements
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
public FutureTask<List<Object>> getFutureTask() {
|
||||
public FutureTask<List<Object>> futureTask() {
|
||||
return futureTask;
|
||||
}
|
||||
|
||||
public Transaction getTransaction() {
|
||||
public Transaction transaction() {
|
||||
return call.transaction;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ public final class QueryFutureList<T> extends BaseFuture<List<T>> implements Fut
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
public FutureTask<List<T>> getFutureTask() {
|
||||
public FutureTask<List<T>> futureTask() {
|
||||
return futureTask;
|
||||
}
|
||||
|
||||
public Transaction getTransaction() {
|
||||
public Transaction transaction() {
|
||||
return call.transaction;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ public final class QueryFutureRowCount<T> extends BaseFuture<Integer> implements
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
public FutureTask<Integer> getFutureTask() {
|
||||
public FutureTask<Integer> futureTask() {
|
||||
return futureTask;
|
||||
}
|
||||
|
||||
public Transaction getTransaction() {
|
||||
public Transaction transaction() {
|
||||
return call.transaction;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ final class RawSqlQueryPlanKey implements CQueryPlanKey {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getPartialKey() + ":r";
|
||||
return partialKey() + ":r";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +35,7 @@ final class RawSqlQueryPlanKey implements CQueryPlanKey {
|
||||
* can be used as a short form proxy for the actual sql.
|
||||
*/
|
||||
@Override
|
||||
public String getPartialKey() {
|
||||
public String partialKey() {
|
||||
return hashCode() + "_0";
|
||||
}
|
||||
|
||||
|
||||
@@ -23,5 +23,5 @@ public interface STreePropertyAssocOne extends STreePropertyAssoc {
|
||||
/**
|
||||
* Return the property value as an entity bean from the parent.
|
||||
*/
|
||||
EntityBean getValueAsEntityBean(EntityBean parentBean);
|
||||
EntityBean valueAsEntityBean(EntityBean parentBean);
|
||||
}
|
||||
|
||||
@@ -136,10 +136,8 @@ public interface STreeType {
|
||||
|
||||
/**
|
||||
* Mark the bean as deleted by setting the softDelete property to true.
|
||||
*
|
||||
* This works also, if there is only a virtual softDelete property computed by a formula.
|
||||
*
|
||||
* If there is no softdelete property, it sets the lazyLoadFailure flag in EBI.
|
||||
* If there is no soft delete property, it sets the lazyLoadFailure flag in EBI.
|
||||
*/
|
||||
void markAsDeleted(EntityBean bean);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum SqlJoinType {
|
||||
* Return the actual SQL join literal taking into account the current join type and the 'default
|
||||
* join type as per deployment cardinality and optionality'.
|
||||
*/
|
||||
public String getLiteral(SqlJoinType deploymentJoinType) {
|
||||
public String literal(SqlJoinType deploymentJoinType) {
|
||||
if (this == SqlJoinType.AUTO) {
|
||||
return deploymentJoinType.literal;
|
||||
}
|
||||
|
||||
@@ -88,33 +88,33 @@ final class SqlTree {
|
||||
return list;
|
||||
}
|
||||
|
||||
String getDistinctOn() {
|
||||
String distinctOn() {
|
||||
return distinctOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String for the actual SQL.
|
||||
*/
|
||||
String getSelectSql() {
|
||||
String selectSql() {
|
||||
assert selectSql != null : "selectSql was null";
|
||||
return selectSql;
|
||||
}
|
||||
|
||||
String getFromSql() {
|
||||
String fromSql() {
|
||||
return fromSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the groupBy clause.
|
||||
*/
|
||||
String getGroupBy() {
|
||||
String groupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the where clause for inheritance.
|
||||
*/
|
||||
String getInheritanceWhereSql() {
|
||||
String inheritanceWhereSql() {
|
||||
return inheritanceWhereSql;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ final class SqlTree {
|
||||
* Return the property that is associated with the many. There can only be one
|
||||
* per SqlSelect. This can be null.
|
||||
*/
|
||||
STreePropertyAssocMany getManyProperty() {
|
||||
STreePropertyAssocMany manyProperty() {
|
||||
return manyProperty;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ final class SqlTreeAlias {
|
||||
for (String propJoin : embeddedPropertyJoins) {
|
||||
String[] split = SplitName.split(propJoin);
|
||||
// the table alias of the parent path
|
||||
String alias = getTableAlias(split[0]);
|
||||
String alias = tableAlias(split[0]);
|
||||
aliasMap.put(propJoin, alias);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ final class SqlTreeAlias {
|
||||
/**
|
||||
* Return the table alias for a given property name.
|
||||
*/
|
||||
String getTableAlias(String prefix) {
|
||||
String tableAlias(String prefix) {
|
||||
if (prefix == null) {
|
||||
return rootTableAlias;
|
||||
} else {
|
||||
@@ -124,7 +124,7 @@ final class SqlTreeAlias {
|
||||
/**
|
||||
* Return an alias using "Many where joins".
|
||||
*/
|
||||
String getTableAliasManyWhere(String prefix) {
|
||||
String tableAliasManyWhere(String prefix) {
|
||||
if (prefix == null) {
|
||||
return rootTableAlias;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ public final class SqlTreeBuilder {
|
||||
this.distinctOnPlatform = builder.isPlatformDistinctOn();
|
||||
this.distinctNoLobs = builder.isPlatformDistinctNoLobs();
|
||||
String fromForUpdate = builder.fromForUpdate(query);
|
||||
CQueryHistorySupport historySupport = builder.getHistorySupport(query);
|
||||
CQueryDraftSupport draftSupport = builder.getDraftSupport(query);
|
||||
CQueryHistorySupport historySupport = builder.historySupport(query);
|
||||
CQueryDraftSupport draftSupport = builder.draftSupport(query);
|
||||
String colAlias = subQuery ? null : columnAliasPrefix;
|
||||
this.ctx = new DefaultDbSqlContext(alias, colAlias, historySupport, draftSupport, fromForUpdate);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public final class SqlTreeBuilder {
|
||||
inheritanceWhereSql = buildWhereClause();
|
||||
groupBy = buildGroupByClause();
|
||||
distinctOn = buildDistinctOn();
|
||||
encryptedProps = ctx.getEncryptedProps();
|
||||
encryptedProps = ctx.encryptedProps();
|
||||
query.incrementAsOfTableCount(ctx.asOfTableCount());
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public final class SqlTreeBuilder {
|
||||
return "1";
|
||||
}
|
||||
rootNode.appendSelect(ctx, subQuery);
|
||||
return trimComma(ctx.getContent());
|
||||
return trimComma(ctx.content());
|
||||
}
|
||||
|
||||
private String buildGroupByClause() {
|
||||
@@ -155,7 +155,7 @@ public final class SqlTreeBuilder {
|
||||
}
|
||||
ctx.startGroupBy();
|
||||
rootNode.appendGroupBy(ctx, subQuery);
|
||||
return trimComma(ctx.getContent());
|
||||
return trimComma(ctx.content());
|
||||
}
|
||||
|
||||
private String buildDistinctOn() {
|
||||
@@ -164,8 +164,8 @@ public final class SqlTreeBuilder {
|
||||
}
|
||||
ctx.startGroupBy();
|
||||
rootNode.appendDistinctOn(ctx, subQuery);
|
||||
String idCols = trimComma(ctx.getContent());
|
||||
return idCols == null ? null : mergeOnDistinct(idCols, predicates.getDbOrderBy());
|
||||
String idCols = trimComma(ctx.content());
|
||||
return idCols == null ? null : mergeOnDistinct(idCols, predicates.dbOrderBy());
|
||||
}
|
||||
|
||||
static String mergeOnDistinct(String idCols, String dbOrderBy) {
|
||||
@@ -201,7 +201,7 @@ public final class SqlTreeBuilder {
|
||||
return "Not Used";
|
||||
}
|
||||
rootNode.appendWhere(ctx);
|
||||
return ctx.getContent();
|
||||
return ctx.content();
|
||||
}
|
||||
|
||||
private String buildFromClause() {
|
||||
@@ -209,14 +209,14 @@ public final class SqlTreeBuilder {
|
||||
return "Not Used";
|
||||
}
|
||||
rootNode.appendFrom(ctx, SqlJoinType.AUTO);
|
||||
return ctx.getContent();
|
||||
return ctx.content();
|
||||
}
|
||||
|
||||
private void buildRoot(STreeType desc) {
|
||||
rootNode = buildSelectChain(null, null, desc, null);
|
||||
if (!rawSql) {
|
||||
alias.addJoin(queryDetail.getFetchPaths(), desc);
|
||||
alias.addJoin(predicates.getPredicateIncludes(), desc);
|
||||
alias.addJoin(predicates.predicateIncludes(), desc);
|
||||
alias.addManyWhereJoins(manyWhereJoins.getPropertyNames());
|
||||
// build set of table alias
|
||||
alias.buildAlias();
|
||||
@@ -348,7 +348,7 @@ public final class SqlTreeBuilder {
|
||||
if (rawSql) {
|
||||
return;
|
||||
}
|
||||
Set<String> predicateIncludes = predicates.getPredicateIncludes();
|
||||
Set<String> predicateIncludes = predicates.predicateIncludes();
|
||||
if (predicateIncludes == null) {
|
||||
return;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ public final class SqlTreeBuilder {
|
||||
|
||||
// remove ManyWhereJoins from the predicateIncludes
|
||||
predicateIncludes.removeAll(manyWhereJoins.getPropertyNames());
|
||||
predicateIncludes.addAll(predicates.getOrderByIncludes());
|
||||
predicateIncludes.addAll(predicates.orderByIncludes());
|
||||
|
||||
// look for predicateIncludes that are not in selectIncludes and add
|
||||
// them as extra joins to the query
|
||||
@@ -641,7 +641,7 @@ public final class SqlTreeBuilder {
|
||||
SqlTreeNodeExtraJoin root = findExtraJoinRoot(includeProp, extraJoin);
|
||||
// register the root because these are the only ones we
|
||||
// return back.
|
||||
rootRegister.put(root.getName(), root);
|
||||
rootRegister.put(root.name(), root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ public final class SqlTreeBuilder {
|
||||
if (extra == null) {
|
||||
return null;
|
||||
} else {
|
||||
SqlTreeNodeExtraJoin extraJoin = new SqlTreeNodeExtraJoin(propertyName, extra.getProperty(), extra.isContainsMany(), temporalMode);
|
||||
SqlTreeNodeExtraJoin extraJoin = new SqlTreeNodeExtraJoin(propertyName, extra.property(), extra.isContainsMany(), temporalMode);
|
||||
joinRegister.put(propertyName, extraJoin);
|
||||
return extraJoin;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ interface SqlTreeLoad {
|
||||
/**
|
||||
* Return the reader for the single attribute query.
|
||||
*/
|
||||
ScalarDataReader<?> getSingleAttributeReader();
|
||||
ScalarDataReader<?> singleAttributeReader();
|
||||
|
||||
}
|
||||
|
||||
@@ -73,14 +73,14 @@ class SqlTreeLoadBean implements SqlTreeLoad {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ScalarDataReader<?> getSingleAttributeReader() {
|
||||
public final ScalarDataReader<?> singleAttributeReader() {
|
||||
if (properties == null || properties.length == 0) {
|
||||
// if we have no property ask first children (in a distinct select with join)
|
||||
if (children.length == 0) {
|
||||
// expected to be a findIds query
|
||||
return desc.idBinder().getBeanProperty();
|
||||
}
|
||||
return children[0].getSingleAttributeReader();
|
||||
return children[0].singleAttributeReader();
|
||||
}
|
||||
if (properties[0] instanceof STreePropertyAssocOne) {
|
||||
STreePropertyAssocOne assocOne = (STreePropertyAssocOne)properties[0];
|
||||
@@ -208,7 +208,7 @@ class SqlTreeLoadBean implements SqlTreeLoad {
|
||||
localBean = null;
|
||||
// ... but there may exist as reference bean in parent which has to be marked as deleted.
|
||||
if (parentBean != null && nodeBeanProp instanceof STreePropertyAssocOne) {
|
||||
contextBean = ((STreePropertyAssocOne)nodeBeanProp).getValueAsEntityBean(parentBean);
|
||||
contextBean = ((STreePropertyAssocOne)nodeBeanProp).valueAsEntityBean(parentBean);
|
||||
if (contextBean != null) {
|
||||
desc.markAsDeleted(contextBean);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
this.disableLazyLoad = disableLazyLoad || !readIdNormal || desc.isRawSqlBased();
|
||||
this.readOnly = readOnly;
|
||||
this.partialObject = props.isPartialObject();
|
||||
this.properties = props.getProps();
|
||||
this.properties = props.props();
|
||||
this.children = myChildren == null ? Collections.emptyList() : myChildren;
|
||||
this.pathMap = createPathMap(prefix, desc);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
if (ctx.length() > 0) {
|
||||
ctx.append(" and");
|
||||
}
|
||||
ctx.append(" ").append(ctx.getTableAlias(prefix)).append(".");
|
||||
ctx.append(" ").append(ctx.tableAlias(prefix)).append(".");
|
||||
ctx.append(inheritInfo.getWhere());
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
if (ctx.length() > 0) {
|
||||
ctx.append(" and");
|
||||
}
|
||||
String ta = ctx.getTableAlias(prefix);
|
||||
String ta = ctx.tableAlias(prefix);
|
||||
ctx.append(" ").append(extraWhere.replace("${ta}", ta));
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
ctx.pushJoin(prefix);
|
||||
ctx.pushTableAlias(prefix);
|
||||
|
||||
baseTableAlias = ctx.getTableAlias(prefix);
|
||||
baseTableAlias = ctx.tableAlias(prefix);
|
||||
// join and return SqlJoinType to use for child joins
|
||||
joinType = appendFromBaseTable(ctx, joinType);
|
||||
for (STreeProperty property : properties) {
|
||||
@@ -325,7 +325,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
appendJoinDiscriminator(ctx);
|
||||
}
|
||||
if (desc.isSoftDelete() && temporalMode != SpiQuery.TemporalMode.SOFT_DELETED) {
|
||||
ctx.append(" and ").append(desc.softDeletePredicate(ctx.getTableAlias(prefix)));
|
||||
ctx.append(" and ").append(desc.softDeletePredicate(ctx.tableAlias(prefix)));
|
||||
}
|
||||
return sqlJoinType;
|
||||
}
|
||||
@@ -335,9 +335,9 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
STreePropertyAssocMany manyProp = (STreePropertyAssocMany) nodeBeanProp;
|
||||
if (manyProp.hasJoinTable()) {
|
||||
|
||||
String alias = ctx.getTableAlias(prefix);
|
||||
String alias = ctx.tableAlias(prefix);
|
||||
String[] split = SplitName.split(prefix);
|
||||
String parentAlias = ctx.getTableAlias(split[0]);
|
||||
String parentAlias = ctx.tableAlias(split[0]);
|
||||
String alias2 = alias + "z_";
|
||||
|
||||
// adding the additional join to the intersection table
|
||||
@@ -354,7 +354,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
|
||||
void appendJoinDiscriminator(DbSqlContext ctx) {
|
||||
if (inheritInfo.getWhere() == null) return;
|
||||
String alias = ctx.getTableAlias(prefix);
|
||||
String alias = ctx.tableAlias(prefix);
|
||||
ctx.append(" and ").append(alias).append(".").append(inheritInfo.getWhere());
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ final class SqlTreeNodeExtraJoin implements SqlTreeNode {
|
||||
return manyJoin;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@@ -115,9 +115,9 @@ final class SqlTreeNodeExtraJoin implements SqlTreeNode {
|
||||
|
||||
manyToMany = true;
|
||||
|
||||
String alias = ctx.getTableAlias(prefix);
|
||||
String alias = ctx.tableAlias(prefix);
|
||||
String[] split = SplitName.split(prefix);
|
||||
String parentAlias = ctx.getTableAlias(split[0]);
|
||||
String parentAlias = ctx.tableAlias(split[0]);
|
||||
String alias2 = alias + "z_";
|
||||
|
||||
TableJoin manyToManyJoin = manyProp.intersectionTableJoin();
|
||||
@@ -146,7 +146,7 @@ final class SqlTreeNodeExtraJoin implements SqlTreeNode {
|
||||
}
|
||||
joinType = assocBeanProperty.addJoin(joinType, prefix, ctx);
|
||||
if (!oneToOneExported && assocBeanProperty.isTargetSoftDelete() && temporalMode != SpiQuery.TemporalMode.SOFT_DELETED) {
|
||||
ctx.append(" and ").append(assocBeanProperty.softDeletePredicate(ctx.getTableAlias(prefix)));
|
||||
ctx.append(" and ").append(assocBeanProperty.softDeletePredicate(ctx.tableAlias(prefix)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -73,7 +73,6 @@ final class SqlTreeNodeManyWhereJoin implements SqlTreeNode {
|
||||
*/
|
||||
@Override
|
||||
public void appendFrom(DbSqlContext ctx, SqlJoinType currentJoinType) {
|
||||
|
||||
// always use the join type as per this many where join
|
||||
// (OUTER for disjunction and otherwise INNER)
|
||||
appendFromBaseTable(ctx, manyJoinType);
|
||||
@@ -84,9 +83,8 @@ final class SqlTreeNodeManyWhereJoin implements SqlTreeNode {
|
||||
* intersection table if this is a ManyToMany node.
|
||||
*/
|
||||
private void appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
|
||||
String alias = ctx.getTableAliasManyWhere(prefix);
|
||||
String parentAlias = ctx.getTableAliasManyWhere(parentPrefix);
|
||||
String alias = ctx.tableAliasManyWhere(prefix);
|
||||
String parentAlias = ctx.tableAliasManyWhere(parentPrefix);
|
||||
|
||||
if (nodeBeanProp instanceof STreePropertyAssocOne) {
|
||||
nodeBeanProp.addJoin(joinType, parentAlias, alias, ctx);
|
||||
|
||||
@@ -16,7 +16,7 @@ final class SqlTreePlan {
|
||||
this.dependentTables = dependentTables;
|
||||
}
|
||||
|
||||
SqlTreeRoot getRootNode() {
|
||||
SqlTreeRoot rootNode() {
|
||||
return (SqlTreeRoot)rootNode;
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ final class SqlTreePlan {
|
||||
* Return the property that is associated with the many. There can only be one
|
||||
* per SqlSelect. This can be null.
|
||||
*/
|
||||
STreePropertyAssocMany getManyProperty() {
|
||||
STreePropertyAssocMany manyProperty() {
|
||||
return manyProperty;
|
||||
}
|
||||
|
||||
STreeProperty[] getEncryptedProps() {
|
||||
STreeProperty[] encryptedProps() {
|
||||
return encryptedProps;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class SqlTreeProperties {
|
||||
}
|
||||
}
|
||||
|
||||
public STreeProperty[] getProps() {
|
||||
public STreeProperty[] props() {
|
||||
return propsList.toArray(new STreeProperty[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,6 @@ interface SqlTreeRoot {
|
||||
/**
|
||||
* Return a Scalar single attribute reader based on the first property.
|
||||
*/
|
||||
ScalarDataReader<?> getSingleAttributeReader();
|
||||
ScalarDataReader<?> singleAttributeReader();
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ final class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPartialKey() {
|
||||
public String partialKey() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ public class TestFutureRowCountErrorHandling extends BaseTestCase {
|
||||
FutureRowCount<Customer> futureRowCount = query.findFutureCount();
|
||||
|
||||
QueryFutureRowCount<Customer> internalRowCount = (QueryFutureRowCount<Customer>) futureRowCount;
|
||||
Transaction t = internalRowCount.getTransaction();
|
||||
Transaction t = internalRowCount.transaction();
|
||||
|
||||
try {
|
||||
futureRowCount.get();
|
||||
@@ -57,7 +57,7 @@ public class TestFutureRowCountErrorHandling extends BaseTestCase {
|
||||
FutureIds<Customer> futureIds = query.findFutureIds();
|
||||
|
||||
QueryFutureIds<Customer> internalFuture = (QueryFutureIds<Customer>) futureIds;
|
||||
Transaction t = internalFuture.getTransaction();
|
||||
Transaction t = internalFuture.transaction();
|
||||
|
||||
try {
|
||||
internalFuture.get();
|
||||
@@ -85,7 +85,7 @@ public class TestFutureRowCountErrorHandling extends BaseTestCase {
|
||||
FutureList<Customer> futureList = query.findFutureList();
|
||||
|
||||
QueryFutureList<Customer> internalFuture = (QueryFutureList<Customer>) futureList;
|
||||
Transaction t = internalFuture.getTransaction();
|
||||
Transaction t = internalFuture.transaction();
|
||||
|
||||
try {
|
||||
internalFuture.get();
|
||||
|
||||
Reference in New Issue
Block a user