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();
}
Aggregations