Search in sources :

Example 11 with SessionFactoryScope

use of org.hibernate.testing.orm.junit.SessionFactoryScope in project hibernate-orm by hibernate.

the class AbstractQueryCacheResultTransformerTest method testMultiSelectNewMapUsingAliasesWithFetchJoinList.

@Test
public void testMultiSelectNewMapUsingAliasesWithFetchJoinList(SessionFactoryScope scope) throws Exception {
    CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {

        @Override
        protected ResultTransformer getResultTransformer() {
            return null;
        }

        @Override
        protected JpaCriteriaQuery getCriteria(Session s) {
            CriteriaBuilder builder = s.getCriteriaBuilder();
            JpaCriteriaQuery criteria = (JpaCriteriaQuery) builder.createQuery(Map.class);
            Root<Student> root = criteria.from(Student.class);
            final Selection<Student> studentAlias = root.alias("s");
            final Selection<Object> pcAlias = root.join("preferredCourse", JoinType.LEFT).alias("pc");
            root.fetch("enrolments", JoinType.LEFT);
            criteria.multiselect(studentAlias, pcAlias);
            criteria.orderBy(builder.asc(root.get("studentNumber")));
            return criteria;
        // return s.createCriteria( Student.class, "s" )
        // .createAlias( "s.preferredCourse", "pc", Criteria.LEFT_JOIN  )
        // .setFetchMode( "enrolments", FetchMode.JOIN )
        // .addOrder( Order.asc( "s.studentNumber" ))
        // .setResultTransformer( Transformers.ALIAS_TO_ENTITY_MAP );
        }
    };
    HqlExecutor hqlSelectNewMapExecutor = new HqlExecutor() {

        @Override
        public Query getQuery(Session s) {
            return s.createQuery("select new map(s as s, pc as pc) from Student s left join s.preferredCourse pc left join fetch s.enrolments order by s.studentNumber");
        }
    };
    ResultChecker checker = results -> {
        List resultList = (List) results;
        assertEquals(2, resultList.size());
        Map yogiMap = (Map) resultList.get(0);
        assertEquals(yogiExpected, yogiMap.get("s"));
        assertEquals(yogiExpected.getPreferredCourse(), yogiMap.get("pc"));
        Map shermanMap = (Map) resultList.get(1);
        assertEquals(shermanExpected, shermanMap.get("s"));
        assertNull(shermanMap.get("pc"));
        if (areDynamicNonLazyAssociationsChecked()) {
            assertTrue(Hibernate.isInitialized(((Student) yogiMap.get("s")).getEnrolments()));
            assertEquals(yogiExpected.getEnrolments(), ((Student) yogiMap.get("s")).getEnrolments());
            assertTrue(Hibernate.isInitialized(((Student) shermanMap.get("s")).getEnrolments()));
            assertEquals(shermanExpected.getEnrolments(), (((Student) shermanMap.get("s")).getEnrolments()));
        }
    };
    runTest(hqlSelectNewMapExecutor, criteriaExecutor, checker, false, scope);
}
Also used : CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) BasicTypeImpl(org.hibernate.type.internal.BasicTypeImpl) ServiceRegistry(org.hibernate.testing.orm.junit.ServiceRegistry) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) JoinType(jakarta.persistence.criteria.JoinType) JpaSelection(org.hibernate.query.criteria.JpaSelection) AvailableSettings(org.hibernate.cfg.AvailableSettings) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Session(org.hibernate.Session) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) HibernateProxy(org.hibernate.proxy.HibernateProxy) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) Query(org.hibernate.query.Query) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Order(jakarta.persistence.criteria.Order) BigIntJdbcType(org.hibernate.type.descriptor.jdbc.BigIntJdbcType) Transformers(org.hibernate.transform.Transformers) Iterator(java.util.Iterator) ListJoin(jakarta.persistence.criteria.ListJoin) ReflectHelper(org.hibernate.internal.util.ReflectHelper) DomainModel(org.hibernate.testing.orm.junit.DomainModel) AliasToBeanConstructorResultTransformer(org.hibernate.transform.AliasToBeanConstructorResultTransformer) Selection(jakarta.persistence.criteria.Selection) CacheMode(org.hibernate.CacheMode) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Test(org.junit.jupiter.api.Test) MapJoin(jakarta.persistence.criteria.MapJoin) List(java.util.List) Root(jakarta.persistence.criteria.Root) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) JpaRoot(org.hibernate.query.criteria.JpaRoot) LongJavaType(org.hibernate.type.descriptor.java.LongJavaType) Setting(org.hibernate.testing.orm.junit.Setting) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) AliasToEntityMapResultTransformer(org.hibernate.transform.AliasToEntityMapResultTransformer) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) Path(jakarta.persistence.criteria.Path) Hibernate(org.hibernate.Hibernate) ResultTransformer(org.hibernate.transform.ResultTransformer) Type(org.hibernate.type.Type) Join(jakarta.persistence.criteria.Join) ArrayList(java.util.ArrayList) List(java.util.List) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Map(java.util.Map) Session(org.hibernate.Session) Test(org.junit.jupiter.api.Test)

Example 12 with SessionFactoryScope

use of org.hibernate.testing.orm.junit.SessionFactoryScope in project hibernate-orm by hibernate.

the class AbstractQueryCacheResultTransformerTest method testMultiEntityProjectionList.

@Test
public void testMultiEntityProjectionList(SessionFactoryScope scope) throws Exception {
    CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {

        @Override
        protected ResultTransformer getResultTransformer() {
            return null;
        }

        @Override
        protected JpaCriteriaQuery getCriteria(Session s) {
            // should use PassThroughTransformer by default
            CriteriaBuilder builder = s.getCriteriaBuilder();
            JpaCriteriaQuery criteria = (JpaCriteriaQuery) builder.createQuery(Object[].class);
            Root<Enrolment> root = criteria.from(Enrolment.class);
            criteria.multiselect(root.get("student"), root.get("semester"), root.get("year"), root.get("course"));
            criteria.orderBy(builder.asc(root.get("studentNumber")));
            return criteria;
        // return s.createCriteria( Enrolment.class, "e" )
        // .setProjection(
        // Projections.projectionList()
        // .add( Property.forName( "e.student" ) )
        // .add( Property.forName( "e.semester" ) )
        // .add( Property.forName( "e.year" ) )
        // .add( Property.forName( "e.course" ) )
        // )
        // .addOrder( Order.asc( "e.studentNumber") );
        }
    };
    HqlExecutor hqlExecutor = new HqlExecutor() {

        @Override
        public Query getQuery(Session s) {
            return s.createQuery("select e.student, e.semester, e.year, e.course from Enrolment e order by e.studentNumber");
        }
    };
    ResultChecker checker = results -> {
        List resultList = (List) results;
        assertEquals(2, resultList.size());
        Object[] yogiObjects = (Object[]) resultList.get(0);
        Object[] shermanObjects = (Object[]) resultList.get(1);
        assertEquals(4, yogiObjects.length);
        // TODO: following is initialized for hql and uninitialied for criteria; why?
        // assertFalse( Hibernate.isInitialized( yogiObjects[ 0 ] ) );
        // assertFalse( Hibernate.isInitialized( shermanObjects[ 0 ] ) );
        assertTrue(yogiObjects[0] instanceof Student);
        assertTrue(shermanObjects[0] instanceof Student);
        assertEquals(yogiEnrolmentExpected.getSemester(), ((Short) yogiObjects[1]).shortValue());
        assertEquals(yogiEnrolmentExpected.getYear(), ((Short) yogiObjects[2]).shortValue());
        assertEquals(courseExpected, yogiObjects[3]);
        assertEquals(shermanEnrolmentExpected.getSemester(), ((Short) shermanObjects[1]).shortValue());
        assertEquals(shermanEnrolmentExpected.getYear(), ((Short) shermanObjects[2]).shortValue());
        assertTrue(shermanObjects[3] instanceof Course);
        assertEquals(courseExpected, shermanObjects[3]);
    };
    runTest(hqlExecutor, criteriaExecutor, checker, false, scope);
}
Also used : CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) BasicTypeImpl(org.hibernate.type.internal.BasicTypeImpl) ServiceRegistry(org.hibernate.testing.orm.junit.ServiceRegistry) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) JoinType(jakarta.persistence.criteria.JoinType) JpaSelection(org.hibernate.query.criteria.JpaSelection) AvailableSettings(org.hibernate.cfg.AvailableSettings) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Session(org.hibernate.Session) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) HibernateProxy(org.hibernate.proxy.HibernateProxy) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) Query(org.hibernate.query.Query) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Order(jakarta.persistence.criteria.Order) BigIntJdbcType(org.hibernate.type.descriptor.jdbc.BigIntJdbcType) Transformers(org.hibernate.transform.Transformers) Iterator(java.util.Iterator) ListJoin(jakarta.persistence.criteria.ListJoin) ReflectHelper(org.hibernate.internal.util.ReflectHelper) DomainModel(org.hibernate.testing.orm.junit.DomainModel) AliasToBeanConstructorResultTransformer(org.hibernate.transform.AliasToBeanConstructorResultTransformer) Selection(jakarta.persistence.criteria.Selection) CacheMode(org.hibernate.CacheMode) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Test(org.junit.jupiter.api.Test) MapJoin(jakarta.persistence.criteria.MapJoin) List(java.util.List) Root(jakarta.persistence.criteria.Root) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) JpaRoot(org.hibernate.query.criteria.JpaRoot) LongJavaType(org.hibernate.type.descriptor.java.LongJavaType) Setting(org.hibernate.testing.orm.junit.Setting) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) AliasToEntityMapResultTransformer(org.hibernate.transform.AliasToEntityMapResultTransformer) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) Path(jakarta.persistence.criteria.Path) Hibernate(org.hibernate.Hibernate) ResultTransformer(org.hibernate.transform.ResultTransformer) Type(org.hibernate.type.Type) Join(jakarta.persistence.criteria.Join) ArrayList(java.util.ArrayList) List(java.util.List) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Session(org.hibernate.Session) Test(org.junit.jupiter.api.Test)

Example 13 with SessionFactoryScope

use of org.hibernate.testing.orm.junit.SessionFactoryScope in project hibernate-orm by hibernate.

the class AbstractQueryCacheResultTransformerTest method testSelectNewMapUsingAliasesList.

@Test
public void testSelectNewMapUsingAliasesList(SessionFactoryScope scope) throws Exception {
    CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {

        @Override
        protected JpaCriteriaQuery getCriteria(Session s) {
            CriteriaBuilder builder = s.getCriteriaBuilder();
            JpaCriteriaQuery criteria = (JpaCriteriaQuery) builder.createQuery();
            Root<Student> root = criteria.from(Student.class);
            criteria.multiselect(root.get("studentNumber").alias("sNumber"), root.get("name").alias("sName"));
            criteria.orderBy(builder.asc(root.get("studentNumber")));
            return criteria;
        // return s.createCriteria( Student.class, "s" )
        // .setProjection(
        // Projections.projectionList()
        // .add( Property.forName( "s.studentNumber" ).as( "sNumber" ) )
        // .add( Property.forName( "s.name" ).as( "sName" ) )
        // )
        // .addOrder( Order.asc( "s.studentNumber" ) )
        // .setResultTransformer( Transformers.ALIAS_TO_ENTITY_MAP );
        }
    };
    HqlExecutor hqlExecutor = new HqlExecutor() {

        @Override
        public Query getQuery(Session s) {
            return s.createQuery("select new map(s.studentNumber as sNumber, s.name as sName) from Student s order by s.studentNumber");
        }
    };
    ResultChecker checker = results -> {
        List resultList = (List) results;
        assertEquals(2, resultList.size());
        Map yogiMap = (Map) resultList.get(0);
        assertEquals(yogiExpected.getStudentNumber(), yogiMap.get("sNumber"));
        assertEquals(yogiExpected.getName(), yogiMap.get("sName"));
        Map shermanMap = (Map) resultList.get(1);
        assertEquals(shermanExpected.getStudentNumber(), shermanMap.get("sNumber"));
        assertEquals(shermanExpected.getName(), shermanMap.get("sName"));
    };
    runTest(hqlExecutor, criteriaExecutor, checker, false, scope);
}
Also used : CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) BasicTypeImpl(org.hibernate.type.internal.BasicTypeImpl) ServiceRegistry(org.hibernate.testing.orm.junit.ServiceRegistry) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) JoinType(jakarta.persistence.criteria.JoinType) JpaSelection(org.hibernate.query.criteria.JpaSelection) AvailableSettings(org.hibernate.cfg.AvailableSettings) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Session(org.hibernate.Session) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) HibernateProxy(org.hibernate.proxy.HibernateProxy) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) Query(org.hibernate.query.Query) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Order(jakarta.persistence.criteria.Order) BigIntJdbcType(org.hibernate.type.descriptor.jdbc.BigIntJdbcType) Transformers(org.hibernate.transform.Transformers) Iterator(java.util.Iterator) ListJoin(jakarta.persistence.criteria.ListJoin) ReflectHelper(org.hibernate.internal.util.ReflectHelper) DomainModel(org.hibernate.testing.orm.junit.DomainModel) AliasToBeanConstructorResultTransformer(org.hibernate.transform.AliasToBeanConstructorResultTransformer) Selection(jakarta.persistence.criteria.Selection) CacheMode(org.hibernate.CacheMode) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Test(org.junit.jupiter.api.Test) MapJoin(jakarta.persistence.criteria.MapJoin) List(java.util.List) Root(jakarta.persistence.criteria.Root) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) JpaRoot(org.hibernate.query.criteria.JpaRoot) LongJavaType(org.hibernate.type.descriptor.java.LongJavaType) Setting(org.hibernate.testing.orm.junit.Setting) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) AliasToEntityMapResultTransformer(org.hibernate.transform.AliasToEntityMapResultTransformer) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) Path(jakarta.persistence.criteria.Path) Hibernate(org.hibernate.Hibernate) ResultTransformer(org.hibernate.transform.ResultTransformer) Type(org.hibernate.type.Type) Join(jakarta.persistence.criteria.Join) ArrayList(java.util.ArrayList) List(java.util.List) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Map(java.util.Map) Session(org.hibernate.Session) Test(org.junit.jupiter.api.Test)

Example 14 with SessionFactoryScope

use of org.hibernate.testing.orm.junit.SessionFactoryScope in project hibernate-orm by hibernate.

the class AbstractQueryCacheResultTransformerTest method testEntityWithNonLazyOneToManyUnique.

@Test
public void testEntityWithNonLazyOneToManyUnique(SessionFactoryScope scope) throws Exception {
    CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {

        @Override
        protected ResultTransformer getResultTransformer() {
            return null;
        }

        @Override
        protected JpaCriteriaQuery getCriteria(Session s) {
            CriteriaBuilder builder = s.getCriteriaBuilder();
            JpaCriteriaQuery<Course> criteria = (JpaCriteriaQuery<Course>) builder.createQuery(Course.class);
            criteria.from(Course.class);
            return criteria;
        // return s.createCriteria( Course.class );
        }
    };
    HqlExecutor hqlExecutor = new HqlExecutor() {

        @Override
        public Query getQuery(Session s) {
            return s.createQuery("from Course");
        }
    };
    ResultChecker checker = results -> {
        assertTrue(results instanceof Course);
        assertEquals(courseExpected, results);
        assertTrue(Hibernate.isInitialized(courseExpected.getCourseMeetings()));
        assertEquals(courseExpected.getCourseMeetings(), courseExpected.getCourseMeetings());
    };
    runTest(hqlExecutor, criteriaExecutor, checker, true, scope);
}
Also used : CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) BasicTypeImpl(org.hibernate.type.internal.BasicTypeImpl) ServiceRegistry(org.hibernate.testing.orm.junit.ServiceRegistry) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) JoinType(jakarta.persistence.criteria.JoinType) JpaSelection(org.hibernate.query.criteria.JpaSelection) AvailableSettings(org.hibernate.cfg.AvailableSettings) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Session(org.hibernate.Session) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) HibernateProxy(org.hibernate.proxy.HibernateProxy) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) Query(org.hibernate.query.Query) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Order(jakarta.persistence.criteria.Order) BigIntJdbcType(org.hibernate.type.descriptor.jdbc.BigIntJdbcType) Transformers(org.hibernate.transform.Transformers) Iterator(java.util.Iterator) ListJoin(jakarta.persistence.criteria.ListJoin) ReflectHelper(org.hibernate.internal.util.ReflectHelper) DomainModel(org.hibernate.testing.orm.junit.DomainModel) AliasToBeanConstructorResultTransformer(org.hibernate.transform.AliasToBeanConstructorResultTransformer) Selection(jakarta.persistence.criteria.Selection) CacheMode(org.hibernate.CacheMode) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Test(org.junit.jupiter.api.Test) MapJoin(jakarta.persistence.criteria.MapJoin) List(java.util.List) Root(jakarta.persistence.criteria.Root) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) JpaRoot(org.hibernate.query.criteria.JpaRoot) LongJavaType(org.hibernate.type.descriptor.java.LongJavaType) Setting(org.hibernate.testing.orm.junit.Setting) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) AliasToEntityMapResultTransformer(org.hibernate.transform.AliasToEntityMapResultTransformer) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) Path(jakarta.persistence.criteria.Path) Hibernate(org.hibernate.Hibernate) ResultTransformer(org.hibernate.transform.ResultTransformer) Type(org.hibernate.type.Type) Join(jakarta.persistence.criteria.Join) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Session(org.hibernate.Session) Test(org.junit.jupiter.api.Test)

Example 15 with SessionFactoryScope

use of org.hibernate.testing.orm.junit.SessionFactoryScope in project hibernate-orm by hibernate.

the class AbstractQueryCacheResultTransformerTest method testMultiProjectionListThenApplyAliasToBean.

@Test
public void testMultiProjectionListThenApplyAliasToBean(SessionFactoryScope scope) throws Exception {
    CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {

        @Override
        protected ResultTransformer getResultTransformer() {
            return null;
        }

        @Override
        protected JpaCriteriaQuery getCriteria(Session s) {
            CriteriaBuilder builder = s.getCriteriaBuilder();
            JpaCriteriaQuery criteria = (JpaCriteriaQuery) builder.createQuery(Object[].class);
            Root<Enrolment> root = criteria.from(Enrolment.class);
            criteria.multiselect(root.get("student").get("name"), root.get("course").get("description"));
            criteria.orderBy(builder.asc(root.get("studentNumber")));
            return criteria;
        // return s.createCriteria( Enrolment.class, "e" )
        // .createAlias( "e.student", "st" )
        // .createAlias( "e.course", "co" )
        // .setProjection(
        // Projections.projectionList()
        // .add( Property.forName( "st.name" ) )
        // .add( Property.forName( "co.description" ) )
        // )
        // .addOrder( Order.asc( "e.studentNumber" ) );
        }
    };
    HqlExecutor hqlExecutor = new HqlExecutor() {

        @Override
        public Query getQuery(Session s) {
            return s.createQuery("select st.name as studentName, co.description as courseDescription from Enrolment e join e.student st join e.course co order by e.studentNumber");
        }
    };
    ResultChecker checker = results -> {
        List resultList = (List) results;
        ResultTransformer transformer = Transformers.aliasToBean(StudentDTO.class);
        String[] aliases = new String[] { "studentName", "courseDescription" };
        for (int i = 0; i < resultList.size(); i++) {
            resultList.set(i, transformer.transformTuple((Object[]) resultList.get(i), aliases));
        }
        assertEquals(2, resultList.size());
        StudentDTO dto = (StudentDTO) resultList.get(0);
        assertEquals(courseExpected.getDescription(), dto.getDescription());
        assertEquals(yogiExpected.getName(), dto.getName());
        dto = (StudentDTO) resultList.get(1);
        assertEquals(courseExpected.getDescription(), dto.getDescription());
        assertEquals(shermanExpected.getName(), dto.getName());
    };
    runTest(hqlExecutor, criteriaExecutor, checker, false, scope);
}
Also used : CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) BasicTypeImpl(org.hibernate.type.internal.BasicTypeImpl) ServiceRegistry(org.hibernate.testing.orm.junit.ServiceRegistry) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) JoinType(jakarta.persistence.criteria.JoinType) JpaSelection(org.hibernate.query.criteria.JpaSelection) AvailableSettings(org.hibernate.cfg.AvailableSettings) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Session(org.hibernate.Session) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) HibernateProxy(org.hibernate.proxy.HibernateProxy) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) Query(org.hibernate.query.Query) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Order(jakarta.persistence.criteria.Order) BigIntJdbcType(org.hibernate.type.descriptor.jdbc.BigIntJdbcType) Transformers(org.hibernate.transform.Transformers) Iterator(java.util.Iterator) ListJoin(jakarta.persistence.criteria.ListJoin) ReflectHelper(org.hibernate.internal.util.ReflectHelper) DomainModel(org.hibernate.testing.orm.junit.DomainModel) AliasToBeanConstructorResultTransformer(org.hibernate.transform.AliasToBeanConstructorResultTransformer) Selection(jakarta.persistence.criteria.Selection) CacheMode(org.hibernate.CacheMode) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Test(org.junit.jupiter.api.Test) MapJoin(jakarta.persistence.criteria.MapJoin) List(java.util.List) Root(jakarta.persistence.criteria.Root) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) JpaRoot(org.hibernate.query.criteria.JpaRoot) LongJavaType(org.hibernate.type.descriptor.java.LongJavaType) Setting(org.hibernate.testing.orm.junit.Setting) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) AliasToEntityMapResultTransformer(org.hibernate.transform.AliasToEntityMapResultTransformer) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) Path(jakarta.persistence.criteria.Path) Hibernate(org.hibernate.Hibernate) ResultTransformer(org.hibernate.transform.ResultTransformer) Type(org.hibernate.type.Type) Join(jakarta.persistence.criteria.Join) AliasToBeanConstructorResultTransformer(org.hibernate.transform.AliasToBeanConstructorResultTransformer) AliasToEntityMapResultTransformer(org.hibernate.transform.AliasToEntityMapResultTransformer) ResultTransformer(org.hibernate.transform.ResultTransformer) ArrayList(java.util.ArrayList) List(java.util.List) JpaCriteriaQuery(org.hibernate.query.criteria.JpaCriteriaQuery) Session(org.hibernate.Session) Test(org.junit.jupiter.api.Test)

Aggregations

SessionFactoryScope (org.hibernate.testing.orm.junit.SessionFactoryScope)68 DomainModel (org.hibernate.testing.orm.junit.DomainModel)67 SessionFactory (org.hibernate.testing.orm.junit.SessionFactory)67 Test (org.junit.jupiter.api.Test)67 ServiceRegistry (org.hibernate.testing.orm.junit.ServiceRegistry)64 Setting (org.hibernate.testing.orm.junit.Setting)64 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)64 List (java.util.List)63 AvailableSettings (org.hibernate.cfg.AvailableSettings)63 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)63 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)63 Query (org.hibernate.query.Query)62 CriteriaBuilder (jakarta.persistence.criteria.CriteriaBuilder)61 Root (jakarta.persistence.criteria.Root)61 ArrayList (java.util.ArrayList)61 CacheMode (org.hibernate.CacheMode)61 Hibernate (org.hibernate.Hibernate)61 Session (org.hibernate.Session)61 ReflectHelper (org.hibernate.internal.util.ReflectHelper)61 ResultTransformer (org.hibernate.transform.ResultTransformer)61