use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class DeleteOneToManyOrphansTest method testOrphanedWhileManagedMergeOwner.
@Test
@TestForIssue(jiraKey = "HHH-9568")
@FailureExpected(jiraKey = "HHH-9568")
public void testOrphanedWhileManagedMergeOwner() {
createData();
EntityManager entityManager = getOrCreateEntityManager();
entityManager.getTransaction().begin();
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();
entityManager.merge(product);
entityManager.getTransaction().commit();
entityManager.close();
entityManager = getOrCreateEntityManager();
entityManager.getTransaction().begin();
product = entityManager.find(Product.class, product.getId());
assertEquals(0, product.getFeatures().size());
results = entityManager.createQuery("from Feature").getResultList();
assertEquals(0, results.size());
results = entityManager.createQuery("from Product").getResultList();
assertEquals(1, results.size());
entityManager.getTransaction().commit();
entityManager.close();
cleanupData();
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class EmbeddedTypeTest method testSingularAttributeAccessByName.
@Test
@TestForIssue(jiraKey = "HHH-4702")
public void testSingularAttributeAccessByName() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
SingularAttribute soldDate_ = em.getMetamodel().embeddable(ShelfLife.class).getSingularAttribute("soldDate");
assertEquals(java.sql.Date.class, soldDate_.getBindableJavaType());
assertEquals(java.sql.Date.class, soldDate_.getType().getJavaType());
assertEquals(java.sql.Date.class, soldDate_.getJavaType());
em.getTransaction().commit();
em.close();
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class QueryWithLiteralsInSelectExpressionTest method testSelectNullLiterals.
@Test
@TestForIssue(jiraKey = "HHH-10230")
public void testSelectNullLiterals() {
final EntityManager entityManager = getOrCreateEntityManager();
try {
final List<Object[]> elements = entityManager.createQuery("SELECT cast(null as boolean), false, e.name FROM MyEntity e", Object[].class).getResultList();
Assert.assertEquals(1, elements.size());
Assert.assertEquals(3, elements.get(0).length);
Assert.assertEquals(null, elements.get(0)[0]);
Assert.assertEquals(false, elements.get(0)[1]);
Assert.assertEquals("Fab", elements.get(0)[2]);
} finally {
entityManager.close();
}
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class HSQLStoreProcedureTest method testGetPositionalParameters.
@Test
@TestForIssue(jiraKey = "HHH-10915")
public void testGetPositionalParameters() {
EntityManager em = entityManagerFactory.createEntityManager();
try {
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("User.inoutproc");
final Set<Parameter<?>> parameters = query.getParameters();
assertThat(parameters.size(), is(2));
try {
query.getParameter(1);
fail("An IllegalArgumentException is expected, The stored procedure has named parameters not positional");
} catch (IllegalArgumentException iae) {
//expected
}
try {
query.getParameter(1, String.class);
fail("An IllegalArgumentException is expected, The stored procedure has named parameters not positional");
} catch (IllegalArgumentException iae) {
//expected
}
} finally {
em.close();
}
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class HSQLStoreProcedureTest method testNamedStoredProcedureExecution.
@Test
@TestForIssue(jiraKey = "HHH-10515")
public void testNamedStoredProcedureExecution() {
EntityManager em = entityManagerFactory.createEntityManager();
try {
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("User.inoutproc");
query.setParameter("arg1", 1);
query.execute();
} finally {
em.close();
}
}
Aggregations