HHH-6100 Bug fix related to CriteriaQuery (JPA) when using XML mappings

This commit is contained in:
Strong Liu 2012-02-20 16:25:14 +08:00
parent ae5d030ae1
commit b0f2658ecf
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,35 @@
package org.hibernate.ejb.test.xml;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import org.junit.Test;
import org.hibernate.ejb.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.TestForIssue;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
@TestForIssue( jiraKey = "HHH-6039, HHH-6100" )
public class JpaEntityNameTest extends BaseEntityManagerFunctionalTestCase {
@Override
protected String[] getMappings() {
return new String[]{"org/hibernate/ejb/test/xml/Qualifier.hbm.xml"};
}
@Test
public void testUsingSimpleHbmInJpa(){
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Qualifier> cq = cb.createQuery(Qualifier.class);
Root<Qualifier> qualifRoot = cq.from(Qualifier.class);
cq.where( cb.equal( qualifRoot.get( "qualifierId" ), 32l ) );
em.createQuery(cq).getResultList();
em.getTransaction().commit();
em.close();
}
}

View File

@ -0,0 +1,34 @@
package org.hibernate.ejb.test.xml;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public class Qualifier {
private Long qualifierId;
private String name;
private String value;
public Long getQualifierId() {
return qualifierId;
}
public void setQualifierId(Long qualifierId) {
this.qualifierId = qualifierId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}