Search in sources :

Example 11 with FailureExpected

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

the class EmbeddableWithOne2ManyTest method testJoinAcrossEmbedded.

@Test
@FailureExpected(jiraKey = "HHH-4883")
public void testJoinAcrossEmbedded() {
    // NOTE : this may or may not work now with HHH-4883 fixed,
    // but i cannot do this checking until HHH-4599 is done.
    Session session = openSession();
    session.beginTransaction();
    session.createQuery("from Person p join p.name.aliases a where a.source = 'FBI'").list();
    session.getTransaction().commit();
    session.close();
}
Also used : Session(org.hibernate.Session) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected)

Example 12 with FailureExpected

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

the class EmbeddableWithOne2ManyTest method testBasicOps.

@Test
@FailureExpected(jiraKey = "HHH-4599")
public void testBasicOps() {
    Session session = openSession();
    session.beginTransaction();
    Alias alias = new Alias("Public Enemy", "Number 1", "FBI");
    session.persist(alias);
    Person person = new Person("John", "Dillinger");
    person.getName().getAliases().add(alias);
    session.persist(person);
    session.getTransaction().commit();
    session.close();
    session = openSession();
    session.beginTransaction();
    person = (Person) session.load(Person.class, person.getId());
    session.delete(person);
    List aliases = session.createQuery("from Alias").list();
    assertEquals(0, aliases.size());
    session.getTransaction().commit();
    session.close();
}
Also used : List(java.util.List) Session(org.hibernate.Session) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected)

Example 13 with FailureExpected

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

the class DefaultCacheConcurrencyPropertyTest method testExplicitDefault.

@Test
@TestForIssue(jiraKey = "HHH-9763")
@FailureExpected(jiraKey = "HHH-9763")
public void testExplicitDefault() {
    final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, "read-only").build();
    try {
        assertEquals("read-only", ssr.getService(ConfigurationService.class).getSettings().get(AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY));
        final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(TheEntity.class).buildMetadata();
        assertEquals(AccessType.READ_ONLY, metadata.getMetadataBuildingOptions().getMappingDefaults().getImplicitCacheAccessType());
        final SessionFactoryImplementor sf = (SessionFactoryImplementor) metadata.buildSessionFactory();
        try {
            final EntityPersister persister = sf.getMetamodel().entityPersister(TheEntity.class.getName());
            assertNotNull(persister.getCacheAccessStrategy());
        } finally {
            sf.close();
        }
    } finally {
        StandardServiceRegistryBuilder.destroy(ssr);
    }
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) ConfigurationService(org.hibernate.engine.config.spi.ConfigurationService) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected) TestForIssue(org.hibernate.testing.TestForIssue)

Example 14 with FailureExpected

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

the class BrokenCollectionEventTest method testUpdateParentNoChildrenToNull.

@Test
@FailureExpected(jiraKey = "unknown")
public void testUpdateParentNoChildrenToNull() {
    CollectionListeners listeners = new CollectionListeners(sessionFactory());
    ParentWithCollection parent = createParentWithNoChildren("parent");
    listeners.clear();
    assertEquals(0, parent.getChildren().size());
    Session s = openSession();
    Transaction tx = s.beginTransaction();
    parent = (ParentWithCollection) s.get(parent.getClass(), parent.getId());
    Collection oldCollection = parent.getChildren();
    parent.newChildren(null);
    tx.commit();
    s.close();
    int index = 0;
    if (((PersistentCollection) oldCollection).wasInitialized()) {
        checkResult(listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++);
    }
    checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++);
    checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++);
    // pre- and post- collection recreate events should be created when updating an entity with a "null" collection
    checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++);
    checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++);
    checkNumberOfResults(listeners, index);
}
Also used : PersistentCollection(org.hibernate.collection.spi.PersistentCollection) Transaction(org.hibernate.Transaction) Collection(java.util.Collection) PersistentCollection(org.hibernate.collection.spi.PersistentCollection) Session(org.hibernate.Session) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected)

Example 15 with FailureExpected

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

the class BrokenCollectionEventTest method testUpdateDetachedParentNoChildrenToNull.

@Test
@FailureExpected(jiraKey = "unknown")
public void testUpdateDetachedParentNoChildrenToNull() {
    CollectionListeners listeners = new CollectionListeners(sessionFactory());
    ParentWithCollection parent = createParentWithNoChildren("parent");
    listeners.clear();
    assertEquals(0, parent.getChildren().size());
    Session s = openSession();
    Transaction tx = s.beginTransaction();
    Collection oldCollection = parent.getChildren();
    parent.newChildren(null);
    s.update(parent);
    tx.commit();
    s.close();
    int index = 0;
    checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++);
    checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++);
    // pre- and post- collection recreate events should be created when updating an entity with a "null" collection
    checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++);
    checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++);
    checkNumberOfResults(listeners, index);
}
Also used : Transaction(org.hibernate.Transaction) Collection(java.util.Collection) PersistentCollection(org.hibernate.collection.spi.PersistentCollection) 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