HHH-7849 Cleaner fix. Added additional regression test.
Conflicts: hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/components/ComponentCriteriaTest.java
This commit is contained in:
parent
d6de1d509a
commit
c1e29a23fd
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -24,17 +24,20 @@
|
|||
package org.hibernate.ejb.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;
|
||||
|
||||
import org.hibernate.ejb.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.jpa.test.criteria.components.Client_;
|
||||
import org.hibernate.jpa.test.criteria.components.Name_;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.ejb.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
/**
|
||||
* @author alan.oleary
|
||||
*/
|
||||
|
@ -63,6 +66,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