collectionTableAlias = elem.getCollectionTableAlias();
}
// TODO: get SQL rendering out of here, create an AST for the join expressions.
// Use the SQL generator grammar to generate the SQL text for the index expression.
JoinSequence joinSequence = fromElement.getJoinSequence();
String[] indexCols = queryableCollection.getIndexColumnNames();
if ( indexCols.length != 1 ) {
throw new QueryException( "composite-index appears in []: " + collectionNode.getPath() );
}
SqlGenerator gen = new SqlGenerator( getSessionFactoryHelper().getFactory() );
try {
gen.simpleExpr( selector ); //TODO: used to be exprNoParens! was this needed?
}
catch (RecognitionException e) {
throw new QueryException( e.getMessage(), e );
}
String selectorExpression = gen.getSQL();
joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression );
List<ParameterSpecification> paramSpecs = gen.getCollectedParameters();
if ( paramSpecs != null ) {
switch ( paramSpecs.size() ) {
case 0:
// nothing to do