/** * Create the immutable version of the intersection join. */ public TableJoin createIntersectionTableJoin() { if (intersectionJoin != null) { return new TableJoin(intersectionJoin); } else { return null; } }
/** * Add table join with table alias based on prefix. */ @Override public SqlJoinType addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx) { return tableJoin.addJoin(joinType, prefix, ctx); }
private TableJoin(TableJoin source, String overrideColumn) { this.table = source.table; this.type = source.type; this.inheritInfo = source.inheritInfo; this.columns = new TableJoinColumn[1]; this.columns[0] = source.columns[0].withOverrideColumn(overrideColumn); this.queryHash = calcQueryHash(); }
/** * Find and return the exported property matching to this property. */ ExportedProperty findMatch(boolean embedded, BeanProperty prop, String matchColumn, TableJoin tableJoin) { String searchTable = tableJoin.getTable(); for (TableJoinColumn column : tableJoin.columns()) { String matchTo = column.getLocalDbColumn(); if (matchColumn.equalsIgnoreCase(matchTo)) { String foreignCol = column.getForeignDbColumn(); return new ExportedProperty(embedded, foreignCol, prop); } } String msg = "Error with the Join on [" + getFullBeanName() + "]. Could not find the matching foreign key for [" + matchColumn + "] in table[" + searchTable + "]?" + " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped?"; throw new PersistenceException(msg); } }
/** * Return true if this association is updateable. */ public boolean isUpdateable() { TableJoinColumn[] columns = tableJoin.columns(); if (columns.length <= 0) { return true; } for (TableJoinColumn column : columns) { if (column.isUpdateable()) { // at least 1 is updatable return true; } } return false; }
public IntersectionRow buildManyDeleteChildren(EntityBean parentBean, List<Object> excludeDetailIds) { IntersectionRow row = new IntersectionRow(tableJoin.getTable(), targetDescriptor); if (excludeDetailIds != null && !excludeDetailIds.isEmpty()) { row.setExcludeIds(excludeDetailIds, getTargetDescriptor()); } buildExport(row, parentBean); return row; }
/** * Copy constructor for ManyToOne inside Embeddable. */ public BeanPropertyAssoc(BeanPropertyAssoc source, BeanPropertyOverride override) { super(source, override); foreignKey = source.foreignKey; extraWhere = source.extraWhere; beanTable = source.beanTable; mappedBy = source.mappedBy; docStoreDoc = source.docStoreDoc; targetType = source.targetType; cascadeInfo = source.cascadeInfo; fetchPreference = source.fetchPreference; tableJoin = source.tableJoin.withOverrideColumn(override.getDbColumn()); }
private MTable createTable() { BeanDescriptor<?> localDesc = manyProp.getBeanDescriptor(); BeanDescriptor<?> targetDesc = manyProp.getTargetDescriptor(); String tableName = intersectionTableJoin.getTable(); MTable table = new MTable(tableName); if (!manyProp.isExcludedFromHistory()) { if (localDesc.isHistorySupport()) { table.setWithHistory(true); } } table.setPkName(ctx.primaryKeyName(tableName)); TableJoinColumn[] columns = intersectionTableJoin.columns(); for (TableJoinColumn column : columns) { addColumn(table, localDesc, column.getForeignDbColumn(), column.getLocalDbColumn()); } TableJoinColumn[] otherColumns = tableJoin.columns(); for (TableJoinColumn otherColumn : otherColumns) { addColumn(table, targetDesc, otherColumn.getLocalDbColumn(), otherColumn.getForeignDbColumn()); } return table; }
/** * Return true if this association is insertable. */ public boolean isInsertable() { TableJoinColumn[] columns = tableJoin.columns(); if (columns.length <= 0) { return true; } for (TableJoinColumn column : columns) { if (column.isInsertable()) { // at least 1 is insertable return true; } } return false; }
sb.append(",m2m:").append(m2mIncludeJoin.getTable());
/** * Copy constructor for ManyToOne inside Embeddable. */ public BeanPropertyAssoc(BeanPropertyAssoc source, BeanPropertyOverride override) { super(source, override); foreignKey = source.foreignKey; extraWhere = source.extraWhere; beanTable = source.beanTable; mappedBy = source.mappedBy; docStoreDoc = source.docStoreDoc; targetType = source.targetType; cascadeInfo = source.cascadeInfo; fetchPreference = source.fetchPreference; tableJoin = source.tableJoin.withOverrideColumn(override.getDbColumn()); }
/** * Add table join with explicit table alias. */ @Override public SqlJoinType addJoin(SqlJoinType joinType, String a1, String a2, DbSqlContext ctx) { return tableJoin.addJoin(joinType, a1, a2, ctx); }
/** * Create the immutable version of the inverse join. */ public TableJoin createInverseTableJoin() { if (inverseJoin != null) { return new TableJoin(inverseJoin); } else { return null; } }
public SqlJoinType addJoin(SqlJoinType joinType, String a1, String a2, DbSqlContext ctx) { String inheritance = inheritInfo != null ? inheritInfo.getWhere() : null; String joinLiteral = joinType.getLiteral(type); ctx.addJoin(joinLiteral, table, columns(), a1, a2, inheritance); return joinType.autoToOuter(type); }
private boolean isSaveIntersection() { if (!many.isManyToMany()) { return true; } return transaction.isSaveAssocManyIntersection(many.getIntersectionTableJoin().getTable(), many.getBeanDescriptor().rootName()); }
/** * Create a TableJoin. */ public TableJoin(DeployTableJoin deploy) { this.table = InternString.intern(deploy.getTable()); this.type = deploy.getType(); this.inheritInfo = deploy.getInheritInfo(); DeployTableJoinColumn[] deployCols = deploy.columns(); this.columns = new TableJoinColumn[deployCols.length]; for (int i = 0; i < deployCols.length; i++) { this.columns[i] = new TableJoinColumn(deployCols[i]); } this.queryHash = calcQueryHash(); }
@Override void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { // add join to support the discriminator column String relativePrefix = ctx.getRelativePrefix(property.name); property.tableJoin.addJoin(joinType, relativePrefix, ctx); }
TableJoin withOverrideColumn(String overrideColumn) { if (columns.length == 1 && overrideColumn != null && !overrideColumn.equals(columns[0].getLocalDbColumn())) { return new TableJoin(this, overrideColumn); } return this; } }