use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class HQLTest method test_hql_group_by_example_4.
@Test
@RequiresDialect(H2Dialect.class)
@RequiresDialect(PostgreSQL81Dialect.class)
@RequiresDialect(MySQL5Dialect.class)
public void test_hql_group_by_example_4() {
doInJPA(this::entityManagerFactory, entityManager -> {
Call call11 = new Call();
call11.setDuration(10);
call11.setTimestamp(Timestamp.from(LocalDateTime.of(2000, 1, 1, 0, 0, 0).toInstant(ZoneOffset.UTC)));
Phone phone = entityManager.createQuery("select p from Phone p where p.calls is empty ", Phone.class).getResultList().get(0);
phone.addCall(call11);
entityManager.flush();
entityManager.clear();
List<Object[]> personTotalCallDurations = entityManager.createQuery("select p, sum( c.duration ) " + "from Call c " + "join c.phone p " + "group by p", Object[].class).getResultList();
assertEquals(2, personTotalCallDurations.size());
});
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class SQLTest method test_sql_hibernate_entity_associations_query_one_to_many_join_example_2.
@Test
@RequiresDialect(H2Dialect.class)
@RequiresDialect(Oracle8iDialect.class)
@RequiresDialect(PostgreSQL82Dialect.class)
public void test_sql_hibernate_entity_associations_query_one_to_many_join_example_2() {
doInJPA(this::entityManagerFactory, entityManager -> {
Session session = entityManager.unwrap(Session.class);
List<Object[]> tuples = session.createSQLQuery("SELECT * " + "FROM Phone ph " + "JOIN phone_call c ON c.phone_id = ph.id").addEntity("phone", Phone.class).addJoin("c", "phone.calls").list();
for (Object[] tuple : tuples) {
Phone phone = (Phone) tuple[0];
Call call = (Call) tuple[1];
}
assertEquals(2, tuples.size());
});
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class SQLTest method test_sql_jpa_entity_associations_named_query_example.
@Test
@RequiresDialect(H2Dialect.class)
@RequiresDialect(Oracle8iDialect.class)
@RequiresDialect(PostgreSQL82Dialect.class)
public void test_sql_jpa_entity_associations_named_query_example() {
doInJPA(this::entityManagerFactory, entityManager -> {
List<Object[]> tuples = entityManager.createNamedQuery("find_person_with_phones_by_name").setParameter("name", "J%").getResultList();
for (Object[] tuple : tuples) {
Person person = (Person) tuple[0];
Phone phone = (Phone) tuple[1];
}
assertEquals(1, tuples.size());
});
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class BeanValidationTest method testTitleColumnHasExpectedLength.
@Test
@RequiresDialect(H2Dialect.class)
public void testTitleColumnHasExpectedLength() {
EntityManager em = getOrCreateEntityManager();
int len = (Integer) em.createNativeQuery("select CHARACTER_MAXIMUM_LENGTH from INFORMATION_SCHEMA.COLUMNS c where c.TABLE_NAME = 'CUPHOLDER' and c.COLUMN_NAME = 'TITLE'").getSingleResult();
assertEquals(64, len);
}
use of org.hibernate.testing.RequiresDialect in project hibernate-orm by hibernate.
the class QueryBuilderTest method testMultiselectWithPredicates.
@Test
@TestForIssue(jiraKey = "HHH-8699")
// For now, restrict to H2. Selecting w/ predicate functions cause issues for too many dialects.
@RequiresDialect(value = H2Dialect.class, jiraKey = "HHH-9092")
public void testMultiselectWithPredicates() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaBuilderImpl cb = (CriteriaBuilderImpl) em.getCriteriaBuilder();
CriteriaQuery<Customer> cq = cb.createQuery(Customer.class);
Root<Customer> r = cq.from(Customer.class);
cq.multiselect(r.get(Customer_.id), r.get(Customer_.name), cb.concat("Hello ", r.get(Customer_.name)), cb.isNotNull(r.get(Customer_.age)));
TypedQuery<Customer> tq = em.createQuery(cq);
tq.getResultList();
em.getTransaction().commit();
em.close();
}
Aggregations