public void processWhereClause( QuerySpecificationBuilder builder,
BooleanBuilder afterWhere,
JoinType joinStyle, Integer firstTableIndex, Integer lastTableIndex )
{
BooleanFactory b = vendor.getBooleanFactory();
LiteralFactory l = vendor.getLiteralFactory();
ColumnsFactory c = vendor.getColumnsFactory();
Iterable<?> collection = predicate.containedValues();
List<QNameJoin> joins = new ArrayList<>();
for( Object value : collection )
{
if( value instanceof Collection<?> )
{
throw new IllegalArgumentException(
"ContainsAllPredicate may not have nested collections as value." );
}
BooleanBuilder conditionForItem = b.booleanBuilder(
b.regexp( c.colName( TABLE_NAME_PREFIX + lastTableIndex,
DBNames.QNAME_TABLE_COLLECTION_PATH_COLUMN_NAME ),
l.s( DBNames.QNAME_TABLE_COLLECTION_PATH_TOP_LEVEL_NAME + ".*{1,}" ) ) );
modifyFromClauseAndWhereClauseToGetValue(
QualifiedName.fromAccessor( predicate.collectionProperty().accessor() ),
value, predicate, false, lastTableIndex,
new ModifiableInt( lastTableIndex ),
DBNames.QNAME_TABLE_VALUE_COLUMN_NAME,
DBNames.QNAME_TABLE_COLLECTION_PATH_TOP_LEVEL_NAME, vendor,
conditionForItem, afterWhere,
builder.getFrom().getTableReferences().iterator().next(),
builder.getGroupBy(), builder.getHaving(),
joins, variables, values, valueSQLTypes );
builder.getWhere().or( conditionForItem.createExpression() );
}
builder.getHaving()
.and(
b.geq(
l.func( "COUNT", c.colName( TABLE_NAME_PREFIX + lastTableIndex,
DBNames.QNAME_TABLE_VALUE_COLUMN_NAME ) ),
l.n( Iterables.count( collection ) ) ) );
}
} //
);