use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class MappedSuperclassType2Test method testMappedSuperclassAccessNoEntity.
@Test
@TestForIssue(jiraKey = "HHH-8534")
@FailureExpected(jiraKey = "HHH-8534")
public void testMappedSuperclassAccessNoEntity() {
// stupid? yes. tck does it? yes.
final PersistenceUnitDescriptorAdapter pu = new PersistenceUnitDescriptorAdapter() {
@Override
public List<String> getManagedClassNames() {
// pass in a MappedSuperclass that is not used in any entity hierarchy
return Arrays.asList(SomeMappedSuperclass.class.getName());
}
};
final Map settings = new HashMap();
settings.put(AvailableSettings.HBM2DDL_AUTO, "create-drop");
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder(pu, settings).build();
try {
ManagedType<SomeMappedSuperclass> type = emf.getMetamodel().managedType(SomeMappedSuperclass.class);
// the issue was in regards to throwing an exception, but also check for nullness
assertNotNull(type);
} finally {
emf.close();
}
}
use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class RemoveOrderingTest method testManyToOne.
@Test
@TestForIssue(jiraKey = "HHH-8550")
@FailureExpected(jiraKey = "HHH-8550")
public void testManyToOne() throws Exception {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
try {
Company company = new Company(1, "acme");
Person person = new Person(1, "joe", company);
em.persist(person);
em.flush();
em.remove(company);
em.remove(person);
em.flush();
em.persist(person);
em.flush();
em.getTransaction().commit();
} catch (Exception e) {
em.getTransaction().rollback();
throw e;
}
em.close();
}
use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class DeleteOneToManyOrphansTest method testOrphanedWhileManaged.
@Test
@TestForIssue(jiraKey = "HHH-9568")
@FailureExpected(jiraKey = "HHH-9568")
public void testOrphanedWhileManaged() {
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.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.FailureExpected in project hibernate-orm by hibernate.
the class DeleteOneToManyOrphansTest method testReplacedWhileManaged.
@Test
@TestForIssue(jiraKey = "HHH-9568")
@FailureExpected(jiraKey = "HHH-9568")
public void testReplacedWhileManaged() {
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());
// Replace with a new Feature instance
product.getFeatures().remove(0);
Feature featureNew = new Feature();
featureNew.setName("Feature 2");
featureNew.setProduct(product);
product.getFeatures().add(featureNew);
entityManager.persist(featureNew);
entityManager.getTransaction().commit();
entityManager.close();
entityManager = getOrCreateEntityManager();
entityManager.getTransaction().begin();
results = entityManager.createQuery("from Feature").getResultList();
assertEquals(1, results.size());
Feature featureQueried = (Feature) results.get(0);
assertEquals(featureNew.getId(), featureQueried.getId());
results = entityManager.createQuery("from Product").getResultList();
assertEquals(1, results.size());
Product productQueried = (Product) results.get(0);
assertEquals(1, productQueried.getFeatures().size());
assertEquals(featureQueried, productQueried.getFeatures().get(0));
entityManager.getTransaction().commit();
entityManager.close();
cleanupData();
}
use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class JoinColumnOrFormulaTest method testUseOfJoinColumnOrFormula.
@Test
@TestForIssue(jiraKey = "HHH-9897")
@FailureExpected(jiraKey = "HHH-9897")
public void testUseOfJoinColumnOrFormula() {
Metadata metadata = new MetadataSources().addAnnotatedClass(A.class).addAnnotatedClass(D.class).buildMetadata();
// Binding to the mapping model works afterQuery the simple change for HHH-9897
// But building the SessionFactory fails in the collection persister trying to
// use the formula (it expects Columns too)
metadata.buildSessionFactory().close();
}
Aggregations