public void appendIsEmpty(SQLBuffer sql, Select sel, Joins joins) { testEmpty(sql, sel, joins, true); }
public void appendSize(SQLBuffer sql, Select sel, Joins joins) { DBDictionary dict = field.getMappingRepository().getDBDictionary(); dict.assertSupport(dict.supportsSubselect, "SupportsSubselect"); ClassMapping[] ind = getIndependentElementMappings(false); if (ind != null && ind.length > 1) throw RelationStrategies.unjoinable(field); ForeignKey fk = getJoinForeignKey(); appendJoinCount(sql, sel, joins, dict, field, fk); }
protected static void appendJoinCount(SQLBuffer sql, Select sel, Joins joins, DBDictionary dict, FieldMapping field, ForeignKey fk) { String fullTable = dict.getFullName(fk.getTable(), false); sql.append("(SELECT COUNT(*) FROM ").append(fullTable). append(" WHERE "); appendUnaliasedJoin(sql, sel, joins, dict, field, fk); sql.append(")"); }
/** * Appends SQL for a sub-select testing whether the container is empty. */ private void testEmpty(SQLBuffer sql, Select sel, Joins joins, boolean empty) { if (empty) sql.append("0 = "); else sql.append("0 < "); appendSize(sql, sel, joins); }
/** * Append SQL for a sub-select testing whether an inverse object exists * for this relation. */ private void testInverseNull(SQLBuffer sql, Select sel, Joins joins, boolean empty) { DBDictionary dict = field.getMappingRepository().getDBDictionary(); dict.assertSupport(dict.supportsSubselect, "SupportsSubselect"); if (field.getIndependentTypeMappings().length != 1) throw RelationStrategies.uninversable(field); if (empty) sql.append("0 = "); else sql.append("0 < "); ForeignKey fk = field.getForeignKey(); ContainerFieldStrategy.appendJoinCount(sql, sel, joins, dict, field, fk); }
protected void lockJoinTables(List<SQLBuffer> sqls, DBDictionary dict, Object id, ClassMapping mapping, JDBCFetchConfiguration fetch, SQLFactory factory) { FieldMapping[] fms = mapping.getFieldMappings(); for (int i = 0; i < fms.length; i++) { Strategy strat = fms[i].getStrategy(); if (strat instanceof ContainerFieldStrategy) { ForeignKey fk = ((ContainerFieldStrategy)strat).getJoinForeignKey(); Select select = factory.newSelect(); select.select(fk.getColumns()); select.whereForeignKey(fk, id, fms[i].getDefiningMapping(), _store); sqls.add(select.toSelect(true, fetch)); } } }
public void appendSize(SQLBuffer sql, Select sel, Joins joins) { DBDictionary dict = field.getMappingRepository().getDBDictionary(); dict.assertSupport(dict.supportsSubselect, "SupportsSubselect"); ClassMapping[] ind = getIndependentElementMappings(false); if (ind != null && ind.length > 1) throw RelationStrategies.unjoinable(field); ForeignKey fk = getJoinForeignKey(); appendJoinCount(sql, sel, joins, dict, field, fk); }
protected static void appendJoinCount(SQLBuffer sql, Select sel, Joins joins, DBDictionary dict, FieldMapping field, ForeignKey fk) { String fullTable = dict.getFullName(fk.getTable(), false); sql.append("(SELECT COUNT(*) FROM ").append(fullTable). append(" WHERE "); appendUnaliasedJoin(sql, sel, joins, dict, field, fk); sql.append(")"); }
/** * Appends SQL for a sub-select testing whether the container is empty. */ private void testEmpty(SQLBuffer sql, Select sel, Joins joins, boolean empty) { if (empty) sql.append("0 = "); else sql.append("0 < "); appendSize(sql, sel, joins); }
/** * Append SQL for a sub-select testing whether an inverse object exists * for this relation. */ private void testInverseNull(SQLBuffer sql, Select sel, Joins joins, boolean empty) { DBDictionary dict = field.getMappingRepository().getDBDictionary(); dict.assertSupport(dict.supportsSubselect, "SupportsSubselect"); if (field.getIndependentTypeMappings().length != 1) throw RelationStrategies.uninversable(field); if (empty) sql.append("0 = "); else sql.append("0 < "); ForeignKey fk = field.getForeignKey(); ContainerFieldStrategy.appendJoinCount(sql, sel, joins, dict, field, fk); }
protected void lockJoinTables(List<SQLBuffer> sqls, DBDictionary dict, Object id, ClassMapping mapping, JDBCFetchConfiguration fetch, SQLFactory factory) { FieldMapping[] fms = mapping.getFieldMappings(); for (int i = 0; i < fms.length; i++) { Strategy strat = fms[i].getStrategy(); if (strat instanceof ContainerFieldStrategy) { ForeignKey fk = ((ContainerFieldStrategy)strat).getJoinForeignKey(); Select select = factory.newSelect(); select.select(fk.getColumns()); select.whereForeignKey(fk, id, fms[i].getDefiningMapping(), _store); sqls.add(select.toSelect(true, fetch)); } } }
public void appendSize(SQLBuffer sql, Select sel, Joins joins) { DBDictionary dict = field.getMappingRepository().getDBDictionary(); dict.assertSupport(dict.supportsSubselect, "SupportsSubselect"); ClassMapping[] ind = getIndependentElementMappings(false); if (ind != null && ind.length > 1) throw RelationStrategies.unjoinable(field); ForeignKey fk = getJoinForeignKey(); appendJoinCount(sql, sel, joins, dict, field, fk); }
public void appendIsNull(SQLBuffer sql, Select sel, Joins joins) { testEmpty(sql, sel, joins, true); }
protected static void appendJoinCount(SQLBuffer sql, Select sel, Joins joins, DBDictionary dict, FieldMapping field, ForeignKey fk) { String fullTable = dict.getFullName(fk.getTable(), false); sql.append("(SELECT COUNT(*) FROM ").append(fullTable). append(" WHERE "); appendUnaliasedJoin(sql, sel, joins, dict, field, fk); sql.append(")"); }
/** * Appends SQL for a sub-select testing whether the container is empty. */ private void testEmpty(SQLBuffer sql, Select sel, Joins joins, boolean empty) { if (empty) sql.append("0 = "); else sql.append("0 < "); appendSize(sql, sel, joins); }
/** * Append SQL for a sub-select testing whether an inverse object exists * for this relation. */ private void testInverseNull(SQLBuffer sql, Select sel, Joins joins, boolean empty) { DBDictionary dict = field.getMappingRepository().getDBDictionary(); dict.assertSupport(dict.supportsSubselect, "SupportsSubselect"); if (field.getIndependentTypeMappings().length != 1) throw RelationStrategies.uninversable(field); if (empty) sql.append("0 = "); else sql.append("0 < "); ForeignKey fk = field.getForeignKey(); ContainerFieldStrategy.appendJoinCount(sql, sel, joins, dict, field, fk); }
protected void lockJoinTables(List<SQLBuffer> sqls, DBDictionary dict, Object id, ClassMapping mapping, JDBCFetchConfiguration fetch, SQLFactory factory) { FieldMapping[] fms = mapping.getFieldMappings(); for (int i = 0; i < fms.length; i++) { Strategy strat = fms[i].getStrategy(); if (strat instanceof ContainerFieldStrategy) { ForeignKey fk = ((ContainerFieldStrategy)strat).getJoinForeignKey(); Select select = factory.newSelect(); select.select(fk.getColumns()); select.whereForeignKey(fk, id, fms[i].getDefiningMapping(), _store); sqls.add(select.toSelect(true, fetch)); } } }
public void appendSize(SQLBuffer sql, Select sel, Joins joins) { DBDictionary dict = field.getMappingRepository().getDBDictionary(); dict.assertSupport(dict.supportsSubselect, "SupportsSubselect"); ClassMapping[] ind = getIndependentElementMappings(false); if (ind != null && ind.length > 1) throw RelationStrategies.unjoinable(field); ForeignKey fk = getJoinForeignKey(); appendJoinCount(sql, sel, joins, dict, field, fk); }
public void appendIsEmpty(SQLBuffer sql, Select sel, Joins joins) { testEmpty(sql, sel, joins, true); }
protected static void appendJoinCount(SQLBuffer sql, Select sel, Joins joins, DBDictionary dict, FieldMapping field, ForeignKey fk) { String fullTable = dict.getFullName(fk.getTable(), false); sql.append("(SELECT COUNT(*) FROM ").append(fullTable). append(" WHERE "); appendUnaliasedJoin(sql, sel, joins, dict, field, fk); sql.append(")"); }