use of org.hibernate.testing.orm.junit.SkipForDialect in project hibernate-orm by hibernate.
the class CriteriaLiteralInSelectExpressionTest method testStringLiteral2.
@Test
@TestForIssue(jiraKey = "HHH-9021")
@SkipForDialect(dialectClass = OracleDialect.class)
@SkipForDialect(dialectClass = DB2Dialect.class)
@SkipForDialect(dialectClass = SQLServerDialect.class)
@SkipForDialect(dialectClass = SybaseDialect.class)
@SkipForDialect(dialectClass = AbstractHANADialect.class)
public void testStringLiteral2(EntityManagerFactoryScope scope) {
scope.inTransaction(entityManager -> {
final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
final CriteriaQuery<Tuple> criteriaQuery = builder.createQuery(Tuple.class);
criteriaQuery.from(MyEntity.class);
criteriaQuery.multiselect(builder.equal(builder.literal(1), builder.literal(2)));
final TypedQuery<Tuple> typedQuery = entityManager.createQuery(criteriaQuery);
final List<Tuple> results = typedQuery.getResultList();
assertThat(results.size(), is(1));
assertThat(results.get(0).getElements().size(), is(1));
assertThat(results.get(0).get(0), is(false));
});
}
use of org.hibernate.testing.orm.junit.SkipForDialect in project hibernate-orm by hibernate.
the class PredicateTest method testQuotientConversion.
@Test
@TestForIssue(jiraKey = "HHH-5803")
@SkipForDialect(dialectClass = CockroachDialect.class, reason = "https://github.com/cockroachdb/cockroach/issues/41943")
public void testQuotientConversion() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaQuery<Order> orderCriteria = builder.createQuery(Order.class);
Root<Order> orderRoot = orderCriteria.from(Order.class);
Long longValue = 999999999L;
Path<Double> doublePath = orderRoot.get(Order_.totalPrice);
Path<Integer> integerPath = orderRoot.get(Order_.customer).get(Customer_.age);
orderCriteria.select(orderRoot);
Predicate p = builder.ge(builder.quot(integerPath, doublePath), longValue);
orderCriteria.where(p);
List<Order> orders = em.createQuery(orderCriteria).getResultList();
assertTrue(orders.size() == 0);
em.getTransaction().commit();
em.close();
}
use of org.hibernate.testing.orm.junit.SkipForDialect in project hibernate-orm by hibernate.
the class PredicateTest method testByteArray.
/**
* Check predicate for field which has simple byte array type (byte[]).
*/
@Test
@JiraKey("HHH-10603")
@SkipForDialect(dialectClass = OracleDialect.class, majorVersion = 12, reason = "Oracle12cDialect uses blob to store byte arrays and it's not possible to compare blobs with simple equality operators.")
public void testByteArray() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaQuery<Order> orderCriteria = builder.createQuery(Order.class);
Root<Order> orderRoot = orderCriteria.from(Order.class);
orderCriteria.select(orderRoot);
Predicate p = builder.equal(orderRoot.get("number"), new byte[] { '1', '2' });
orderCriteria.where(p);
List<Order> orders = em.createQuery(orderCriteria).getResultList();
assertTrue(orders.size() == 0);
em.getTransaction().commit();
em.close();
}
use of org.hibernate.testing.orm.junit.SkipForDialect in project hibernate-orm by hibernate.
the class StatelessSessionQueryTest method testNewQueryApis.
@Test
@TestForIssue(jiraKey = "HHH-13194")
@SkipForDialect(dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = " HANA doesn't support tables consisting of only a single auto-generated column")
public void testNewQueryApis(SessionFactoryScope scope) {
final String queryString = "from Contact c join fetch c.org o join fetch o.country";
scope.inStatelessSession(session -> {
Query query = session.createQuery(queryString);
assertEquals(1, query.getResultList().size());
query = session.getNamedQuery(Contact.class.getName() + ".contacts");
assertEquals(1, query.getResultList().size());
NativeQuery sqlQuery = session.createNativeQuery("select id from Contact");
assertEquals(1, sqlQuery.getResultList().size());
});
}
use of org.hibernate.testing.orm.junit.SkipForDialect in project hibernate-orm by hibernate.
the class ManyToManySizeTest method testSizeAsSelectExpressionWithInnerJoin.
@Test
@SkipForDialect(dialectClass = DerbyDialect.class, reason = "Derby doesn't see that the subquery is functionally dependent")
public void testSizeAsSelectExpressionWithInnerJoin(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
final List results = session.createQuery("select new org.hibernate.orm.test.query.hql.size.ManyToManySizeTest$CompanyDto(" + " c.id, c.name, size( c.customers ) )" + " from Company c inner join c.customers cu" + " group by c.id, c.name" + " order by c.id").list();
assertThat(results.size(), is(2));
final CompanyDto companyDto1 = (CompanyDto) results.get(0);
assertThat(companyDto1.getId(), is(1));
assertThat(companyDto1.getName(), is("Company 1"));
assertThat(companyDto1.getSizeCustomer(), is(1));
final CompanyDto companyDto2 = (CompanyDto) results.get(1);
assertThat(companyDto2.getId(), is(2));
assertThat(companyDto2.getName(), is("Company 2"));
assertThat(companyDto2.getSizeCustomer(), is(2));
});
}
Aggregations