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 );
|
fromClause.addJoinByPathMap( componentPath, this );
|
||||||
initializeComponentJoin( new ComponentFromElementType( this ) );
|
initializeComponentJoin( new ComponentFromElementType( this ) );
|
||||||
|
|
||||||
String[] cols = origin.getPropertyMapping( "" ).toColumns( getTableAlias(), componentProperty );
|
this.columns = origin.getPropertyMapping( "" ).toColumns( getTableAlias(), componentProperty );
|
||||||
this.columns = cols.length == 0 ? new String[] { null} : cols;
|
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
for ( int j = 0; j < columns.length; j++ ) {
|
for ( int j = 0; j < columns.length; j++ ) {
|
||||||
final String column = columns[j];
|
final String column = columns[j];
|
||||||
|
|
|
@ -174,11 +174,12 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
|
||||||
}
|
}
|
||||||
setText( joinedFragment );
|
setText( joinedFragment );
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else if ( columnExpressions.length > 0 ) {
|
||||||
setText( columnExpressions[0] );
|
setText( columnExpressions[0] );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ package org.hibernate.jpa.test.criteria.components;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.TypedQuery;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
@ -65,6 +66,17 @@ public class ComponentCriteriaTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
em.close();
|
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 = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
em.createQuery( "delete Client" ).executeUpdate();
|
em.createQuery( "delete Client" ).executeUpdate();
|
||||||
|
|
Loading…
Reference in New Issue