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); return addJoin(joinType, a1, a2, ctx); }
public SqlJoinType 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); SqlJoinType returnJoinType = addJoin(joinType, a1, a2, ctx); ctx.append("and ").append(a2).append(predicate); return returnJoinType; }
protected SqlJoinType appendFromAsJoin(DbSqlContext ctx, SqlJoinType joinType) { if (nodeBeanProp instanceof STreePropertyAssocMany) { STreePropertyAssocMany manyProp = (STreePropertyAssocMany) nodeBeanProp; if (manyProp.hasJoinTable()) { String alias = ctx.getTableAlias(prefix); String[] split = SplitName.split(prefix); String parentAlias = ctx.getTableAlias(split[0]); String alias2 = alias + "z_"; // adding the additional join to the intersection table TableJoin manyToManyJoin = manyProp.getIntersectionTableJoin(); manyToManyJoin.addJoin(joinType, parentAlias, alias2, ctx); if (!manyProp.isExcludedFromHistory()) { intersectionAsOfTableAlias = true; } return nodeBeanProp.addJoin(joinType, alias2, alias, ctx); } } return nodeBeanProp.addJoin(joinType, prefix, ctx); }
/** * Append columns for foreign key columns. */ @Override void appendSelect(DbSqlContext ctx, boolean subQuery) { if (!subQuery) { // add discriminator column String relativePrefix = ctx.getRelativePrefix(property.getName()); String tableAlias = ctx.getTableAlias(relativePrefix); ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn()); } property.importedId.sqlAppend(ctx); } }
/** * Join to base table for this node. This includes a join to the intersection * table if this is a ManyToMany node. */ public SqlJoinType appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) { SqlJoinType sqlJoinType = appendFromAsJoin(ctx, joinType); if (temporalMode != SpiQuery.TemporalMode.SOFT_DELETED && desc.isSoftDelete()) { // add the soft delete predicate to the join clause ctx.append("and ").append(desc.getSoftDeletePredicate(ctx.getTableAlias(prefix))).append(" "); } return sqlJoinType; }
protected void appendExtraWhere(DbSqlContext ctx) { if (extraWhere != null) { if (ctx.length() > 0) { ctx.append(" and"); } String ta = ctx.getTableAlias(prefix); String ew = StringHelper.replaceString(extraWhere, "${ta}", ta); ctx.append(" ").append(ew).append(" "); } }
String alias = ctx.getTableAlias(prefix); String[] split = SplitName.split(prefix); String parentAlias = ctx.getTableAlias(split[0]); String alias2 = alias + "z_";
/** * Append to the FROM clause for this node. */ @Override public void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { if (nodeBeanProp != null && nodeBeanProp.isFormula()) { // add joins for formula beans nodeBeanProp.appendFrom(ctx, joinType); } ctx.pushJoin(prefix); ctx.pushTableAlias(prefix); baseTableAlias = ctx.getTableAlias(prefix); // join and return SqlJoinType to use for child joins joinType = appendFromBaseTable(ctx, joinType); for (STreeProperty property : properties) { // usually nothing... except for 1-1 Exported property.appendFrom(ctx, joinType); } for (SqlTreeNode aChildren : children) { aChildren.appendFrom(ctx, joinType); } ctx.popTableAlias(); ctx.popJoin(); }
@Override public void appendWhere(DbSqlContext ctx) { // Only apply inheritance to root node as any join will already have the inheritance join include - see TableJoin if (inheritInfo != null && nodeBeanProp == null) { if (!inheritInfo.isRoot()) { // restrict to this type and sub types of this type. if (ctx.length() > 0) { ctx.append(" and"); } ctx.append(" ").append(ctx.getTableAlias(prefix)).append("."); ctx.append(inheritInfo.getWhere()).append(" "); } } appendExtraWhere(ctx); for (SqlTreeNode aChildren : children) { // recursively add to the where clause any // fixed predicates (extraWhere etc) aChildren.appendWhere(ctx); } }
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); return addJoin(joinType, a1, a2, ctx); }
public SqlJoinType 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); SqlJoinType returnJoinType = addJoin(joinType, a1, a2, ctx); ctx.append("and ").append(a2).append(predicate); return returnJoinType; }
protected SqlJoinType appendFromAsJoin(DbSqlContext ctx, SqlJoinType joinType) { if (nodeBeanProp instanceof STreePropertyAssocMany) { STreePropertyAssocMany manyProp = (STreePropertyAssocMany) nodeBeanProp; if (manyProp.hasJoinTable()) { String alias = ctx.getTableAlias(prefix); String[] split = SplitName.split(prefix); String parentAlias = ctx.getTableAlias(split[0]); String alias2 = alias + "z_"; // adding the additional join to the intersection table TableJoin manyToManyJoin = manyProp.getIntersectionTableJoin(); manyToManyJoin.addJoin(joinType, parentAlias, alias2, ctx); if (!manyProp.isExcludedFromHistory()) { intersectionAsOfTableAlias = true; } return nodeBeanProp.addJoin(joinType, alias2, alias, ctx); } } return nodeBeanProp.addJoin(joinType, prefix, ctx); }
/** * Append columns for foreign key columns. */ @Override void appendSelect(DbSqlContext ctx, boolean subQuery) { if (!subQuery) { // add discriminator column String relativePrefix = ctx.getRelativePrefix(property.getName()); String tableAlias = ctx.getTableAlias(relativePrefix); ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn()); } property.importedId.sqlAppend(ctx); } }
/** * Join to base table for this node. This includes a join to the intersection * table if this is a ManyToMany node. */ public SqlJoinType appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) { SqlJoinType sqlJoinType = appendFromAsJoin(ctx, joinType); if (temporalMode != SpiQuery.TemporalMode.SOFT_DELETED && desc.isSoftDelete()) { // add the soft delete predicate to the join clause ctx.append("and ").append(desc.getSoftDeletePredicate(ctx.getTableAlias(prefix))).append(" "); } return sqlJoinType; }
protected void appendExtraWhere(DbSqlContext ctx) { if (extraWhere != null) { if (ctx.length() > 0) { ctx.append(" and"); } String ta = ctx.getTableAlias(prefix); String ew = StringHelper.replaceString(extraWhere, "${ta}", ta); ctx.append(" ").append(ew).append(" "); } }
String alias = ctx.getTableAlias(prefix); String[] split = SplitName.split(prefix); String parentAlias = ctx.getTableAlias(split[0]); String alias2 = alias + "z_";
/** * Append to the FROM clause for this node. */ @Override public void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { if (nodeBeanProp != null && nodeBeanProp.isFormula()) { // add joins for formula beans nodeBeanProp.appendFrom(ctx, joinType); } ctx.pushJoin(prefix); ctx.pushTableAlias(prefix); baseTableAlias = ctx.getTableAlias(prefix); // join and return SqlJoinType to use for child joins joinType = appendFromBaseTable(ctx, joinType); for (STreeProperty property : properties) { // usually nothing... except for 1-1 Exported property.appendFrom(ctx, joinType); } for (SqlTreeNode aChildren : children) { aChildren.appendFrom(ctx, joinType); } ctx.popTableAlias(); ctx.popJoin(); }
@Override public void appendWhere(DbSqlContext ctx) { // Only apply inheritance to root node as any join will already have the inheritance join include - see TableJoin if (inheritInfo != null && nodeBeanProp == null) { if (!inheritInfo.isRoot()) { // restrict to this type and sub types of this type. if (ctx.length() > 0) { ctx.append(" and"); } ctx.append(" ").append(ctx.getTableAlias(prefix)).append("."); ctx.append(inheritInfo.getWhere()).append(" "); } } appendExtraWhere(ctx); for (SqlTreeNode aChildren : children) { // recursively add to the where clause any // fixed predicates (extraWhere etc) aChildren.appendWhere(ctx); } }