use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class DeleteOneToManyOrphansTest method testOrphanedWhileManaged.
@Test
@TestForIssue(jiraKey = "HHH-9568")
@FailureExpected(jiraKey = "HHH-9568")
public void testOrphanedWhileManaged(EntityManagerFactoryScope scope) {
Long productId = scope.fromTransaction(entityManager -> {
List results = entityManager.createQuery("from Feature").getResultList();
assertEquals(1, results.size());
results = entityManager.createQuery("from Product").getResultList();
assertEquals(1, results.size());
Product product = (Product) results.get(0);
assertEquals(1, product.getFeatures().size());
product.getFeatures().clear();
return product.getId();
});
scope.inTransaction(entityManager -> {
Product _product = entityManager.find(Product.class, productId);
assertEquals(0, _product.getFeatures().size());
List results = entityManager.createQuery("from Feature").getResultList();
assertEquals(0, results.size());
results = entityManager.createQuery("from Product").getResultList();
assertEquals(1, results.size());
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class NotFoundExceptionManyToOneTest method testQueryOwnerSelection.
@Test
@JiraKey("HHH-15060")
@FailureExpected(reason = "EntityNotFoundException thrown rather than ObjectNotFoundException; " + "ObjectNotFoundException is thrown but caught and then converted to EntityNotFoundException")
public void testQueryOwnerSelection(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
scope.inTransaction((session) -> {
final String hql = "select c from Coin c";
try {
session.createQuery(hql, Coin.class).getResultList();
fail("Expecting ObjectNotFoundException for broken fk");
} catch (ObjectNotFoundException expected) {
// 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 ");
assertThat(expected.getEntityName()).isEqualTo(Currency.class.getName());
assertThat(expected.getIdentifier()).isEqualTo(1);
}
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class NotFoundIgnoreManyToOneTest method testQueryAssociationSelection.
@Test
@JiraKey("HHH-15060")
@FailureExpected(reason = "Has zero results because of inner-join; & the select w/ inner-join is executed twice for some odd reason")
public void testQueryAssociationSelection(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
scope.inTransaction((session) -> {
final String hql = "select c.currency from Coin c";
session.createQuery(hql, Currency.class).getResultList();
final List<Currency> currencies = session.createSelectionQuery(hql, Currency.class).getResultList();
assertThat(currencies).hasSize(1);
assertThat(currencies.get(0)).isNull();
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.FailureExpected in project hibernate-orm by hibernate.
the class NotFoundIgnoreManyToOneTest 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.createSelectionQuery(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.FailureExpected in project hibernate-orm by hibernate.
the class SQLServerStoredProcedureCrossDatabaseTest method testStoredProcedureViaJPANamedParameters.
@Test
@FailureExpected(jiraKey = "HHH-12704", reason = "SQL Server JDBC Driver does not support registering name parameters properly")
public void testStoredProcedureViaJPANamedParameters(EntityManagerFactoryScope scope) {
scope.inTransaction(entityManager -> {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery(DATABASE_NAME + ".dbo.sp_square_number");
query.registerStoredProcedureParameter("outputNumber", Integer.class, ParameterMode.OUT);
query.setParameter("inputNumber", 7);
query.execute();
int result = (int) query.getOutputParameterValue("outputNumber");
assertEquals(49, result);
});
}
Aggregations