HHH-2159 : NullPointerException in FromElement#findIntendedAliasedFromElementBasedOnCrazyJPARequirements

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14050 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2007-10-03 03:50:47 +00:00
parent 4a7615fd42
commit 430a94b5ab
2 changed files with 10 additions and 3 deletions

View File

@ -85,13 +85,14 @@ public class FromClause extends HqlSqlWalkerNode implements HqlSqlTokenTypes, Di
}
void addDuplicateAlias(String alias, FromElement element) {
fromElementByClassAlias.put( alias, element );
if ( alias != null ) {
fromElementByClassAlias.put( alias, element );
}
}
private void checkForDuplicateClassAlias(String classAlias) throws SemanticException {
if ( classAlias != null && fromElementByClassAlias.containsKey( classAlias ) ) {
throw new SemanticException( "Duplicate definition of alias '"
+ classAlias + "'" );
throw new SemanticException( "Duplicate definition of alias '" + classAlias + "'" );
}
}

View File

@ -41,6 +41,12 @@ public class JPAQLComplianceTest extends AbstractJPATest {
s.close();
}
public void testIdentifierCasesensitivityAndDuplicateFromElements() throws Exception {
Session s = openSession();
s.createQuery( "select e from MyEntity e where exists (select 1 from MyEntity e2 where e2.other.name = 'something' and e2.other.other = e)" );
s.close();
}
public void testGeneratedSubquery() {
Session s = openSession();
s.createQuery( "select c FROM Item c WHERE c.parts IS EMPTY" ).list();