use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class MappedSuperclassWithOverriddenAttributeTest method testStaticMetamodelOverridden.
@Test
@FailureExpected(jiraKey = "HHH-11078")
public void testStaticMetamodelOverridden() {
EntityManagerFactory emf = TestingEntityManagerFactoryGenerator.generateEntityManagerFactory(AvailableSettings.LOADED_CLASSES, Arrays.asList(Product2.class));
try {
assertNotNull(Product1_.overridenName, "'Product1_.overridenName' should not be null)");
assertNotNull(Product2_.overridenName, "'Product2_.overridenName' should not be null)");
// is null
} finally {
emf.close();
}
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class SelectionQueryExampleTests method namedQueryTest.
@Test
@FailureExpected(reason = "Illegal selection query")
public void namedQueryTest(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
// tag::example-hql-named-selection-query-query[]
// cannot be validated until execution
Query query = session.getNamedQuery("delete_Person");
query.getResultList();
// end::example-hql-named-selection-query-query[]
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class SelectionQueryExampleTests method queryTest.
@Test
@FailureExpected(reason = "Illegal selection query")
public void queryTest(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
// tag::example-hql-selection-query-query[]
// cannot be validated until execution
Query query = session.createQuery("delete Person");
query.getResultList();
// end::example-hql-selection-query-query[]
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class PersistentSetTest method testCompositeElementMerging.
@Test
@FailureExpected(jiraKey = "HHH-2485")
public void testCompositeElementMerging(SessionFactoryScope scope) {
Container container = new Container("p1");
scope.inTransaction(session -> {
Container.Content c1 = new Container.Content("c1");
container.getContents().add(c1);
session.save(container);
});
CollectionStatistics stats = scope.getSessionFactory().getStatistics().getCollectionStatistics(Container.class.getName() + ".contents");
long recreateCount = stats.getRecreateCount();
long updateCount = stats.getUpdateCount();
container.setName("another name");
scope.inTransaction(session -> {
session.merge(container);
});
assertEquals(1, container.getContents().size());
assertEquals(recreateCount, stats.getRecreateCount());
assertEquals(updateCount, stats.getUpdateCount());
scope.inTransaction(session -> {
Container c = session.get(Container.class, container.getId());
assertEquals(1, container.getContents().size());
session.delete(container);
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class TransientOverrideAsPersistentJoined method testCriteriaQueryByRootClassAndOverridenProperty.
@Test
@FailureExpected(jiraKey = "HHH-12981")
public void testCriteriaQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
scope.inTransaction(session -> {
final CriteriaBuilder builder = session.getCriteriaBuilder();
final CriteriaQuery<Employee> query = builder.createQuery(Employee.class);
final Root<Employee> root = query.from(Employee.class);
final ParameterExpression<String> parameter = builder.parameter(String.class, "title");
final Predicate predicateEditor = builder.equal(builder.treat(root, Editor.class).get("title"), parameter);
query.where(predicateEditor);
final Employee editor = session.createQuery(query).setParameter("title", "Senior Editor").getSingleResult();
assertThat(editor, instanceOf(Editor.class));
final Predicate predicateWriter = builder.equal(builder.treat(root, Writer.class).get("title"), parameter);
query.where(predicateWriter);
final Employee writer = session.createQuery(query).setParameter("title", "Writing").getSingleResult();
assertThat(writer, instanceOf(Writer.class));
assertNotNull(((Writer) writer).getGroup());
assertEquals(writer.getTitle(), ((Writer) writer).getGroup().getName());
});
}
Aggregations