[hibernate-commits] Hibernate SVN: r15867 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Tue Feb 3 09:23:15 EST 2009
Author: steve.ebersole at jboss.com
Date: 2009-02-03 09:23:14 -0500 (Tue, 03 Feb 2009)
New Revision: 15867
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java
Log:
HHH-3749 : limit FromElement reuse based on alias
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java 2009-02-03 14:22:51 UTC (rev 15866)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java 2009-02-03 14:23:14 UTC (rev 15867)
@@ -434,7 +434,13 @@
//
///////////////////////////////////////////////////////////////////////////////
- if ( elem == null ) {
+ boolean found = elem != null;
+ // even though we might find a pre-existing element by join path, for FromElements originating in a from-clause
+ // we should only ever use the found element if the aliases match (null != null here). Implied joins are
+ // always (?) ok to reuse.
+ boolean useFoundFromElement = found && ( elem.isImplied() || areSame( classAlias, elem.getClassAlias() ) );
+
+ if ( ! useFoundFromElement ) {
// If this is an implied join in a from element, then use the impled join type which is part of the
// tree parser's state (set by the gramamar actions).
JoinSequence joinSequence = getSessionFactoryHelper()
@@ -458,13 +464,19 @@
);
}
else {
- currentFromClause.addDuplicateAlias(classAlias, elem);
+ // NOTE : addDuplicateAlias() already performs nullness checks on the alias.
+ currentFromClause.addDuplicateAlias( classAlias, elem );
}
setImpliedJoin( elem );
getWalker().addQuerySpaces( elem.getEntityPersister().getQuerySpaces() );
setFromElement( elem ); // This 'dot' expression now refers to the resulting from element.
}
+ private boolean areSame(String alias1, String alias2) {
+ // again, null != null here
+ return !StringHelper.isEmpty( alias1 ) && !StringHelper.isEmpty( alias2 ) && alias1.equals( alias2 );
+ }
+
private void setImpliedJoin(FromElement elem) {
this.impliedJoin = elem;
if ( getFirstChild().getType() == SqlTokenTypes.DOT ) {
More information about the hibernate-commits
mailing list