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