HHH-952 : corrected formatting from previous version in trunk
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14210 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
a6729c155b
commit
069c575e36
|
@ -1,5 +1,6 @@
|
|||
//$Id: SubqueryExpression.java 7365 2005-07-04 02:40:29Z oneovthafew $
|
||||
package org.hibernate.criterion;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
|
@ -25,7 +26,7 @@ public abstract class SubqueryExpression implements Criterion {
|
|||
private QueryParameters params;
|
||||
private Type[] types;
|
||||
private CriteriaQueryTranslator innerQuery;
|
||||
|
||||
|
||||
protected Type[] getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
@ -40,22 +41,22 @@ public abstract class SubqueryExpression implements Criterion {
|
|||
|
||||
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
|
||||
throws HibernateException {
|
||||
|
||||
final SessionFactoryImplementor factory = criteriaQuery.getFactory();
|
||||
|
||||
final SessionFactoryImplementor factory = criteriaQuery.getFactory();
|
||||
final OuterJoinLoadable persister = (OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );
|
||||
|
||||
createAndSetInnerQuery( criteriaQuery, factory );
|
||||
|
||||
CriteriaJoinWalker walker = new CriteriaJoinWalker(
|
||||
persister,
|
||||
innerQuery,
|
||||
factory,
|
||||
criteriaImpl,
|
||||
criteriaImpl.getEntityOrClassName(),
|
||||
new HashMap(),
|
||||
innerQuery.getRootSQLALias());
|
||||
persister,
|
||||
innerQuery,
|
||||
factory,
|
||||
criteriaImpl,
|
||||
criteriaImpl.getEntityOrClassName(),
|
||||
new HashMap(),
|
||||
innerQuery.getRootSQLALias());
|
||||
|
||||
String sql = walker.getSQLString();
|
||||
String sql = walker.getSQLString();
|
||||
|
||||
final StringBuffer buf = new StringBuffer()
|
||||
.append( toLeftSqlString(criteria, criteriaQuery) );
|
||||
|
@ -67,11 +68,11 @@ public abstract class SubqueryExpression implements Criterion {
|
|||
|
||||
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
|
||||
throws HibernateException {
|
||||
//the following two lines were added to ensure that this.params is not null, which
|
||||
//can happen with two-deep nested subqueries
|
||||
SessionFactoryImplementor factory = criteriaQuery.getFactory();
|
||||
createAndSetInnerQuery(criteriaQuery, factory);
|
||||
|
||||
//the following two lines were added to ensure that this.params is not null, which
|
||||
//can happen with two-deep nested subqueries
|
||||
SessionFactoryImplementor factory = criteriaQuery.getFactory();
|
||||
createAndSetInnerQuery(criteriaQuery, factory);
|
||||
|
||||
Type[] ppTypes = params.getPositionalParameterTypes();
|
||||
Object[] ppValues = params.getPositionalParameterValues();
|
||||
TypedValue[] tv = new TypedValue[ppTypes.length];
|
||||
|
@ -81,34 +82,35 @@ public abstract class SubqueryExpression implements Criterion {
|
|||
return tv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the inner query used to extract some useful information about
|
||||
* types, since it is needed in both methods.
|
||||
* @param criteriaQuery
|
||||
* @param factory
|
||||
*/
|
||||
private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, final SessionFactoryImplementor factory) {
|
||||
if ( innerQuery == null ) {
|
||||
//with two-deep subqueries, the same alias would get generated for
|
||||
//both using the old method (criteriaQuery.generateSQLAlias()), so
|
||||
//that is now used as a fallback if the main criteria alias isn't set
|
||||
String alias;
|
||||
if ( this.criteriaImpl.getAlias() == null ) {
|
||||
alias = criteriaQuery.generateSQLAlias();
|
||||
} else {
|
||||
alias = this.criteriaImpl.getAlias() + "_";
|
||||
}
|
||||
/**
|
||||
* Creates the inner query used to extract some useful information about
|
||||
* types, since it is needed in both methods.
|
||||
* @param criteriaQuery
|
||||
* @param factory
|
||||
*/
|
||||
private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, final SessionFactoryImplementor factory) {
|
||||
if ( innerQuery == null ) {
|
||||
//with two-deep subqueries, the same alias would get generated for
|
||||
//both using the old method (criteriaQuery.generateSQLAlias()), so
|
||||
//that is now used as a fallback if the main criteria alias isn't set
|
||||
String alias;
|
||||
if ( this.criteriaImpl.getAlias() == null ) {
|
||||
alias = criteriaQuery.generateSQLAlias();
|
||||
}
|
||||
else {
|
||||
alias = this.criteriaImpl.getAlias() + "_";
|
||||
}
|
||||
|
||||
innerQuery = new CriteriaQueryTranslator(
|
||||
factory,
|
||||
criteriaImpl,
|
||||
criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
|
||||
alias,
|
||||
criteriaQuery
|
||||
);
|
||||
innerQuery = new CriteriaQueryTranslator(
|
||||
factory,
|
||||
criteriaImpl,
|
||||
criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
|
||||
alias,
|
||||
criteriaQuery
|
||||
);
|
||||
|
||||
params = innerQuery.getQueryParameters();
|
||||
types = innerQuery.getProjectedTypes();
|
||||
}
|
||||
}
|
||||
params = innerQuery.getQueryParameters();
|
||||
types = innerQuery.getProjectedTypes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//$Id: AbstractEntityJoinWalker.java 11080 2007-01-23 16:29:18Z steve.ebersole@jboss.com $
|
||||
//$Id: AbstractEntityJoinWalker.java 11081 2007-01-23 16:31:13Z steve.ebersole@jboss.com $
|
||||
package org.hibernate.loader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,7 +20,7 @@ import org.hibernate.util.CollectionHelper;
|
|||
/**
|
||||
* Abstract walker for walkers which begin at an entity (criteria
|
||||
* queries and entity loaders).
|
||||
*
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
public abstract class AbstractEntityJoinWalker extends JoinWalker {
|
||||
|
@ -55,10 +55,11 @@ public abstract class AbstractEntityJoinWalker extends JoinWalker {
|
|||
getFactory(),
|
||||
CollectionHelper.EMPTY_MAP
|
||||
) );
|
||||
|
||||
|
||||
initPersisters(allAssociations, lockMode);
|
||||
initStatementString( whereString, orderByString, lockMode);
|
||||
}
|
||||
|
||||
protected final void initProjection(
|
||||
final String projectionString,
|
||||
final String whereString,
|
||||
|
|
|
@ -58,12 +58,12 @@ public class CriteriaJoinWalker extends AbstractEntityJoinWalker {
|
|||
final Map enabledFilters) {
|
||||
this(persister, translator, factory, criteria, rootEntityName, enabledFilters, null);
|
||||
}
|
||||
|
||||
|
||||
public CriteriaJoinWalker(
|
||||
final OuterJoinLoadable persister,
|
||||
final OuterJoinLoadable persister,
|
||||
final CriteriaQueryTranslator translator,
|
||||
final SessionFactoryImplementor factory,
|
||||
final CriteriaImpl criteria,
|
||||
final SessionFactoryImplementor factory,
|
||||
final CriteriaImpl criteria,
|
||||
final String rootEntityName,
|
||||
final Map enabledFilters,
|
||||
final String alias) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//$Id: CriteriaQueryTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
|
||||
//$Id: CriteriaQueryTest.java 10976 2006-12-12 23:22:26Z steve.ebersole@jboss.com $
|
||||
package org.hibernate.test.criteria;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -153,8 +153,8 @@ public class CriteriaQueryTest extends FunctionalTestCase {
|
|||
.list();
|
||||
|
||||
session.createCriteria(Student.class)
|
||||
.add( Property.forName("name").eqAll(dc) )
|
||||
.list();
|
||||
.add( Property.forName("name").eqAll(dc) )
|
||||
.list();
|
||||
|
||||
session.createCriteria(Student.class)
|
||||
.add( Subqueries.in("Gavin King", dc) )
|
||||
|
|
Loading…
Reference in New Issue