Search in sources :

Example 1 with SqlFragmentPredicate

use of org.hibernate.persister.internal.SqlFragmentPredicate in project hibernate-orm by hibernate.

the class AbstractEntityPersister method applyWhereRestrictions.

@Override
public void applyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState) {
    if (sqlWhereStringTemplate == null) {
        return;
    }
    final String alias;
    final TableReference tableReference;
    if (tableGroup == null || (tableReference = tableGroup.resolveTableReference(sqlWhereStringTableExpression)) == null) {
        alias = null;
    } else {
        if (useQualifier && tableReference.getIdentificationVariable() != null) {
            alias = tableReference.getIdentificationVariable();
        } else {
            alias = tableReference.getTableId();
        }
    }
    final String fragment = StringHelper.replace(sqlWhereStringTemplate, Template.TEMPLATE, alias);
    predicateConsumer.accept(new SqlFragmentPredicate(fragment));
}
Also used : NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) TableReference(org.hibernate.sql.ast.tree.from.TableReference) SqlFragmentPredicate(org.hibernate.persister.internal.SqlFragmentPredicate)

Example 2 with SqlFragmentPredicate

use of org.hibernate.persister.internal.SqlFragmentPredicate in project hibernate-orm by hibernate.

the class AbstractCollectionPersister method applyWhereFragments.

/**
 * Applies all defined {@link org.hibernate.annotations.Where}
 */
private static void applyWhereFragments(Consumer<Predicate> predicateConsumer, String alias, String template) {
    if (template == null) {
        return;
    }
    final String fragment = StringHelper.replace(template, Template.TEMPLATE, alias);
    if (StringHelper.isEmpty(fragment)) {
        return;
    }
    predicateConsumer.accept(new SqlFragmentPredicate(fragment));
}
Also used : SqlFragmentPredicate(org.hibernate.persister.internal.SqlFragmentPredicate)

Aggregations

SqlFragmentPredicate (org.hibernate.persister.internal.SqlFragmentPredicate)2 NamedTableReference (org.hibernate.sql.ast.tree.from.NamedTableReference)1 TableReference (org.hibernate.sql.ast.tree.from.TableReference)1