use of org.hibernate.testing.orm.junit.JiraKey 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.JiraKey in project hibernate-orm by hibernate.
the class NotFoundIgnoreOneToOneTest method testQueryImplicitPathDereferencePredicate.
@Test
@JiraKey("HHH-15060")
@FailureExpected(reason = "Bad results due to cross-join")
public void testQueryImplicitPathDereferencePredicate(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
scope.inTransaction((session) -> {
final String hql = "select c from Coin c where c.currency.id = 1";
final List<Coin> coins = session.createQuery(hql, Coin.class).getResultList();
assertThat(coins).hasSize(1);
assertThat(coins.get(0).getCurrency()).isNull();
// technically we could use a subsequent-select rather than a join...
assertThat(statementInspector.getSqlQueries()).hasSize(1);
assertThat(statementInspector.getSqlQueries().get(0)).contains(" join ");
assertThat(statementInspector.getSqlQueries().get(0)).doesNotContain(" inner ");
});
}
use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class NotFoundIgnoreOneToOneTest method testQueryOwnerSelection.
@Test
@JiraKey("HHH-15060")
public void testQueryOwnerSelection(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
scope.inTransaction((session) -> {
final String hql = "select c from Coin c";
final List<Coin> coins = session.createQuery(hql, Coin.class).getResultList();
assertThat(coins).hasSize(1);
assertThat(coins.get(0).getCurrency()).isNull();
// at the moment this uses a subsequent-select. on the bright side, it is at least eagerly fetched.
assertThat(statementInspector.getSqlQueries()).hasSize(2);
assertThat(statementInspector.getSqlQueries().get(0)).contains(" from Coin ");
assertThat(statementInspector.getSqlQueries().get(1)).contains(" from Currency ");
// but I believe a jon would be better
// assertThat( statementInspector.getSqlQueries() ).hasSize( 1 );
// assertThat( statementInspector.getSqlQueries().get( 0 ) ).contains( " join " );
// assertThat( statementInspector.getSqlQueries().get( 0 ) ).doesNotContain( " inner " );
});
}
use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testOutAndSysRefCursorAsOutParameter.
@Test
@JiraKey("HHH-12138")
public void testOutAndSysRefCursorAsOutParameter(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
StoredProcedureQuery function = session.createNamedStoredProcedureQuery("outAndRefCursor");
function.execute();
Integer value = (Integer) function.getSingleResult();
assertEquals(Integer.valueOf(1), value);
assertEquals(1, function.getOutputParameterValue(1));
Assertions.assertFalse(function.hasMoreResults());
});
}
use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testHibernateProcedureCallRefCursor.
@Test
@JiraKey("HHH-12138")
public void testHibernateProcedureCallRefCursor(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
ProcedureCall call = session.createStoredProcedureCall("sp_person_phones");
final ProcedureParameter<Long> inParam = call.registerParameter(1, Long.class, ParameterMode.IN);
call.setParameter(inParam, 1L);
call.registerParameter(2, Class.class, ParameterMode.REF_CURSOR);
Output output = call.getOutputs().getCurrent();
// noinspection unchecked
List<Object[]> postComments = ((ResultSetOutput) output).getResultList();
assertEquals(2, postComments.size());
});
}
Aggregations