HHH-7849 Cleaner fix. Added additional regression test.

This commit is contained in:
brmeyer 2012-12-10 14:16:20 -05:00
parent c75b045adc
commit 598c6d3d25
3 changed files with 16 additions and 4 deletions

View File

@ -57,8 +57,7 @@ public class ComponentJoin extends FromElement {
fromClause.addJoinByPathMap( componentPath, this );
initializeComponentJoin( new ComponentFromElementType( this ) );
String[] cols = origin.getPropertyMapping( "" ).toColumns( getTableAlias(), componentProperty );
this.columns = cols.length == 0 ? new String[] { null} : cols;
this.columns = origin.getPropertyMapping( "" ).toColumns( getTableAlias(), componentProperty );
StringBuilder buf = new StringBuilder();
for ( int j = 0; j < columns.length; j++ ) {
final String column = columns[j];

View File

@ -174,11 +174,12 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
}
setText( joinedFragment );
}
return true;
}
else {
else if ( columnExpressions.length > 0 ) {
setText( columnExpressions[0] );
return true;
}
return true;
}
return false;
}

View File

@ -25,6 +25,7 @@ package org.hibernate.jpa.test.criteria.components;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
@ -64,6 +65,17 @@ public class ComponentCriteriaTest extends BaseEntityManagerFunctionalTestCase {
Assert.assertEquals( 1, list.size() );
em.getTransaction().commit();
em.close();
// HHH-5792
em = getOrCreateEntityManager();
em.getTransaction().begin();
TypedQuery< Client > q = em.createQuery(
"SELECT c FROM Client c JOIN c.name n WHERE n.firstName = '"
+ client.getName().getFirstName() + "'",
Client.class );
Assert.assertEquals( 1, q.getResultList().size() );
em.getTransaction().commit();
em.close();
em = getOrCreateEntityManager();
em.getTransaction().begin();