SubqueryExpressionpublic abstract class SubqueryExpression extends Object implements Criterion
Fields Summary |
---|
private org.hibernate.impl.CriteriaImpl | criteriaImpl | private String | quantifier | private String | op | private org.hibernate.engine.QueryParameters | params | private org.hibernate.type.Type[] | types |
Constructors Summary |
---|
protected SubqueryExpression(String op, String quantifier, DetachedCriteria dc)
this.criteriaImpl = dc.getCriteriaImpl();
this.quantifier = quantifier;
this.op = op;
|
Methods Summary |
---|
public org.hibernate.engine.TypedValue[] | getTypedValues(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)
Type[] types = params.getPositionalParameterTypes();
Object[] values = params.getPositionalParameterValues();
TypedValue[] tv = new TypedValue[types.length];
for ( int i=0; i<types.length; i++ ) {
tv[i] = new TypedValue( types[i], values[i], EntityMode.POJO );
}
return tv;
| protected org.hibernate.type.Type[] | getTypes()
return types;
| protected abstract java.lang.String | toLeftSqlString(org.hibernate.Criteria criteria, CriteriaQuery outerQuery)
| public java.lang.String | toSqlString(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)
final SessionImplementor session = ( (CriteriaImpl) criteria ).getSession(); //ugly!
final SessionFactoryImplementor factory = session.getFactory();
final OuterJoinLoadable persister = (OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );
CriteriaQueryTranslator innerQuery = new CriteriaQueryTranslator(
factory,
criteriaImpl,
criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
criteriaQuery.generateSQLAlias(),
criteriaQuery
);
params = innerQuery.getQueryParameters(); //TODO: bad lifecycle....
types = innerQuery.getProjectedTypes();
//String filter = persister.filterFragment( innerQuery.getRootSQLALias(), session.getEnabledFilters() );
String sql = new Select( factory.getDialect() )
.setWhereClause( innerQuery.getWhereCondition() )
.setGroupByClause( innerQuery.getGroupBy() )
.setSelectClause( innerQuery.getSelect() )
.setFromClause(
persister.fromTableFragment( innerQuery.getRootSQLALias() ) +
persister.fromJoinFragment( innerQuery.getRootSQLALias(), true, false )
)
.toStatementString();
final StringBuffer buf = new StringBuffer()
.append( toLeftSqlString(criteria, criteriaQuery) );
if (op!=null) buf.append(' ").append(op).append(' ");
if (quantifier!=null) buf.append(quantifier).append(' ");
return buf.append('(").append(sql).append(')")
.toString();
|
|