[hibernate-commits] Hibernate SVN: r15865 - core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Tue Feb 3 09:20:50 EST 2009
Author: steve.ebersole at jboss.com
Date: 2009-02-03 09:20:50 -0500 (Tue, 03 Feb 2009)
New Revision: 15865
Modified:
core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java
Log:
HHH-3749 : limit FromElement reuse based on alias
Modified: core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java 2009-02-03 01:16:57 UTC (rev 15864)
+++ core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java 2009-02-03 14:20:50 UTC (rev 15865)
@@ -411,7 +411,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()
@@ -435,13 +441,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