Search in sources :

Example 46 with RequiresDialectFeature

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

the class ClobLocatorTest method testUnboundedClobLocatorAccess.

@Test
@RequiresDialectFeature(value = DialectChecks.SupportsUnboundedLobLocatorMaterializationCheck.class, comment = "database/driver does not support materializing a LOB locator outside the owning transaction")
public void testUnboundedClobLocatorAccess() throws Throwable {
    // Note: unbounded mutation of the underlying lob data is completely
    // unsupported; most databases would not allow such a construct anyway.
    // Thus here we are only testing materialization...
    String original = buildString(CLOB_SIZE, 'x');
    Session s = openSession();
    s.beginTransaction();
    LobHolder entity = new LobHolder();
    entity.setClobLocator(s.getLobHelper().createClob(original));
    s.save(entity);
    s.getTransaction().commit();
    s.close();
    // load the entity with the clob locator, and close the session/transaction;
    // at that point it is unbounded...
    s = openSession();
    s.beginTransaction();
    entity = s.get(LobHolder.class, entity.getId());
    s.getTransaction().commit();
    s.close();
    assertEquals(CLOB_SIZE, entity.getClobLocator().length());
    assertEquals(original, extractData(entity.getClobLocator()));
    s = openSession();
    s.beginTransaction();
    s.delete(entity);
    s.getTransaction().commit();
    s.close();
}
Also used : Session(org.hibernate.Session) Test(org.junit.Test) RequiresDialectFeature(org.hibernate.testing.RequiresDialectFeature)

Aggregations

RequiresDialectFeature (org.hibernate.testing.RequiresDialectFeature)46 Test (org.junit.Test)45 Session (org.hibernate.Session)34 Transaction (org.hibernate.Transaction)17 TestForIssue (org.hibernate.testing.TestForIssue)10 EntityManager (javax.persistence.EntityManager)8 HashMap (java.util.HashMap)7 RequiresDialect (org.hibernate.testing.RequiresDialect)7 List (java.util.List)6 Callable (java.util.concurrent.Callable)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 Query (org.hibernate.Query)6 LockTimeoutException (javax.persistence.LockTimeoutException)5 ArrayList (java.util.ArrayList)4 QuerySyntaxException (org.hibernate.hql.internal.ast.QuerySyntaxException)4 SkipForDialect (org.hibernate.testing.SkipForDialect)4 Query (javax.persistence.Query)3 BigDecimal (java.math.BigDecimal)2 Map (java.util.Map)2 QueryTimeoutException (javax.persistence.QueryTimeoutException)2