HHH-7849 Cleaner fix. Added additional regression test.
This commit is contained in:
parent
c75b045adc
commit
598c6d3d25
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue