use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class BasicCriteriaExecutionTests method testExecutingBasicCriteriaQueryParameterPredicate.
// Doing ... where ? = ? ... is only allowed in a few DBs. Since this is useless, we don't bother to emulate this
@Test
@RequiresDialect(H2Dialect.class)
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support comparing parameters against each other")
public void testExecutingBasicCriteriaQueryParameterPredicate(SessionFactoryScope scope) {
scope.inStatelessTransaction(session -> {
final HibernateCriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
final CriteriaQuery<Object> criteria = criteriaBuilder.createQuery();
final Root<BasicEntity> root = criteria.from(BasicEntity.class);
criteria.select(root);
final ParameterExpression<Integer> param = criteriaBuilder.parameter(Integer.class);
criteria.where(criteriaBuilder.equal(param, param));
session.createQuery(criteria).setParameter(param, 1).list();
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class BasicCriteriaExecutionTests method testIt.
@Test
public void testIt(SessionFactoryScope scope) {
scope.inTransaction(session -> {
final HibernateCriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
CriteriaQuery<BasicEntity> criteria = criteriaBuilder.createQuery(BasicEntity.class);
criteria.from(BasicEntity.class);
session.createQuery(criteria).list();
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class BasicCriteriaExecutionTests method testExecutingBasicCriteriaQuery.
@Test
public void testExecutingBasicCriteriaQuery(SessionFactoryScope scope) {
scope.inTransaction(session -> {
final HibernateCriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
final CriteriaQuery<Object> criteria = criteriaBuilder.createQuery();
final Root<BasicEntity> root = criteria.from(BasicEntity.class);
criteria.select(root);
session.createQuery(criteria).list();
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class BasicCriteriaExecutionTests method testExecutingBasicCriteriaQueryParameterPredicateInStatelessSession.
// Doing ... where ? = ? ... is only allowed in a few DBs. Since this is useless, we don't bother to emulate this
@Test
@RequiresDialect(H2Dialect.class)
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support comparing parameters against each other")
public void testExecutingBasicCriteriaQueryParameterPredicateInStatelessSession(SessionFactoryScope scope) {
scope.inStatelessTransaction(session -> {
final HibernateCriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
final CriteriaQuery<Object> criteria = criteriaBuilder.createQuery();
final Root<BasicEntity> root = criteria.from(BasicEntity.class);
criteria.select(root);
final ParameterExpression<Integer> param = criteriaBuilder.parameter(Integer.class);
criteria.where(criteriaBuilder.equal(param, param));
session.createQuery(criteria).setParameter(param, 1).list();
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class BasicCriteriaExecutionTests method testExecutingBasicCriteriaQueryInStatelessSession.
@Test
public void testExecutingBasicCriteriaQueryInStatelessSession(SessionFactoryScope scope) {
scope.inTransaction(session -> {
final HibernateCriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
final CriteriaQuery<Object> criteria = criteriaBuilder.createQuery();
final Root<BasicEntity> root = criteria.from(BasicEntity.class);
criteria.select(root);
session.createQuery(criteria).list();
});
}
Aggregations