Search in sources :

Example 51 with FailureExpected

use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.

the class PluralAttributeExpressionsTest method testElementMapIsEmptyCriteria.

@Test
@TestForIssue(jiraKey = "HHH-11225")
@FailureExpected(jiraKey = "HHH-6686")
public void testElementMapIsEmptyCriteria() {
    doInJPA(this::entityManagerFactory, entityManager -> {
        final HibernateCriteriaBuilder cb = (HibernateCriteriaBuilder) entityManager.getCriteriaBuilder();
        final CriteriaQuery<MapEntity> criteria = cb.createQuery(MapEntity.class);
        final Root<MapEntity> root = criteria.from(MapEntity.class);
        criteria.select(root).where(cb.isMapEmpty(root.get(MapEntity_.localized)));
        entityManager.createQuery(criteria).getResultList();
    });
}
Also used : HibernateCriteriaBuilder(org.hibernate.query.criteria.HibernateCriteriaBuilder) MapEntity(org.hibernate.jpa.test.metamodel.MapEntity) Test(org.junit.Test) AbstractMetamodelSpecificTest(org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest) FailureExpected(org.hibernate.testing.FailureExpected) TestForIssue(org.hibernate.testing.TestForIssue)

Example 52 with FailureExpected

use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.

the class MergeNotNullCollectionUsingIdentityTest method testOneToManyNotNullCollection.

@Test
@FailureExpected(jiraKey = "HHH-9979")
public void testOneToManyNotNullCollection() {
    Parent parent = new Parent();
    Child child = new Child();
    List<Child> children = new ArrayList<Child>();
    children.add(child);
    child.setParent(parent);
    parent.setChildren(children);
    Session s = openSession();
    Transaction t = s.beginTransaction();
    parent = (Parent) s.merge(parent);
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    s.delete(parent);
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) ArrayList(java.util.ArrayList) Session(org.hibernate.Session) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected)

Example 53 with FailureExpected

use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.

the class QueryAndSQLTest method testNativeQueryWithFormulaAttributeWithoutAlias.

@Test
@FailureExpected(jiraKey = "HHH-2225")
public void testNativeQueryWithFormulaAttributeWithoutAlias() {
    String sql = "select TABLE_NAME , sysdate() from all_tables  where TABLE_NAME = 'AUDIT_ACTIONS' ";
    Session s = openSession();
    s.beginTransaction();
    s.createSQLQuery(sql).addEntity("t", AllTables.class).list();
    s.getTransaction().commit();
    s.close();
}
Also used : Session(org.hibernate.Session) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected)

Example 54 with FailureExpected

use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.

the class ComponentTest method testComponentQueryMethodNoParensFailureExpected.

@Test
@RequiresDialect(value = SybaseASE15Dialect.class)
@FailureExpected(jiraKey = "HHH-3150")
public void testComponentQueryMethodNoParensFailureExpected() {
    // Sybase should translate "current_timestamp" in HQL to "getdate()";
    // This fails currently due to HHH-3510. The following test should be
    // deleted and testComponentQueries() should be updated (as noted
    // in that test case) when HHH-3510 is fixed.
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Employee emp = new Employee();
    emp.setHireDate(new Date());
    emp.setPerson(new Person());
    emp.getPerson().setName("steve");
    emp.getPerson().setDob(new Date());
    s.save(emp);
    s.createQuery("from Employee e where e.person = ('steve', current_timestamp)").list();
    s.delete(emp);
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) Date(java.util.Date) Session(org.hibernate.Session) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected) RequiresDialect(org.hibernate.testing.RequiresDialect)

Example 55 with FailureExpected

use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.

the class ProxyTest method testRefreshLockUninitializedProxyThenRead.

@Test
@FailureExpected(jiraKey = "HHH-1645", message = "Session.refresh with LockOptions does not work on uninitialized proxies")
public void testRefreshLockUninitializedProxyThenRead() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    DataPoint dp = newPersistentDataPoint(s);
    dp = (DataPoint) s.load(DataPoint.class, new Long(dp.getId()));
    assertFalse(Hibernate.isInitialized(dp));
    s.refresh(dp, LockOptions.UPGRADE);
    dp.getX();
    assertSame(LockOptions.UPGRADE.getLockMode(), s.getCurrentLockMode(dp));
    s.delete(dp);
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) Session(org.hibernate.Session) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected)

Aggregations

FailureExpected (org.hibernate.testing.FailureExpected)59 Test (org.junit.Test)58 Session (org.hibernate.Session)39 Transaction (org.hibernate.Transaction)23 TestForIssue (org.hibernate.testing.TestForIssue)14 EntityManager (javax.persistence.EntityManager)12 List (java.util.List)7 ArrayList (java.util.ArrayList)4 Date (java.util.Date)3 MetadataSources (org.hibernate.boot.MetadataSources)3 RequiresDialect (org.hibernate.testing.RequiresDialect)3 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Callable (java.util.concurrent.Callable)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 Query (javax.persistence.Query)2