HHH-5755 - javax.persistence.criteria.Expression.as() is broken
This commit is contained in:
parent
fa6a2f6159
commit
830d4cd2ab
|
@ -39,15 +39,14 @@ import org.hibernate.ejb.metamodel.Product_;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
public class CastTest extends AbstractMetamodelSpecificTest {
|
||||
|
||||
private static final int QUANTITY = 2;
|
||||
private CriteriaBuilder builder;
|
||||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() throws Exception {
|
||||
super.buildEntityManagerFactory();
|
||||
builder = entityManagerFactory().getCriteriaBuilder();
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-5755" )
|
||||
public void testCastToString() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
Product product = new Product();
|
||||
|
@ -61,12 +60,10 @@ public class CastTest extends AbstractMetamodelSpecificTest {
|
|||
em.persist( product );
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCastToString() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
CriteriaBuilder builder = em.getCriteriaBuilder();
|
||||
CriteriaQuery<Product> criteria = builder.createQuery( Product.class );
|
||||
Root<Product> root = criteria.from( Product.class );
|
||||
criteria.where( builder.equal(root.get(Product_.quantity).as( String.class ), builder.literal(String.valueOf(QUANTITY))) );
|
||||
|
@ -74,5 +71,11 @@ public class CastTest extends AbstractMetamodelSpecificTest {
|
|||
Assert.assertEquals( 1, result.size() );
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
|
||||
em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.createQuery( "delete Product" ).executeUpdate();
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue