1 | public void testUnboundedBlobLocatorAccess() throws Throwable {↵ | | 1 | public void testUnboundedClobLocatorAccess() throws Throwable {↵
|
2 | if ( ! supportsUnboundedLobLocatorMaterialization() ) {↵ | | 2 | if ( ! supportsUnboundedLobLocatorMaterialization() ) {↵
|
3 | return;↵ | | 3 | return;↵
|
4 | }↵ | | 4 | }↵
|
|
5 | // Note: unbounded mutation of the underlying lob data is completely↵ | | 5 | // Note: unbounded mutation of the underlying lob data is completely↵
|
6 | // unsupported; most databases would not allow such a construct anyway.↵ | | 6 | // unsupported; most databases would not allow such a construct anyway.↵
|
7 | // Thus here we are only testing materialization...↵ | | 7 | // Thus here we are only testing materialization...↵
|
|
8 | byte[] original = buildRecursively( BLOB_SIZE, true );↵ | | 8 | String original = buildRecursively( CLOB_SIZE, 'x' );↵
|
|
9 | Session s = openSession();↵ | | 9 | Session s = openSession();↵
|
10 | s.beginTransaction();↵ | | 10 | s.beginTransaction();↵
|
11 | LobHolder entity = new LobHolder();↵ | | 11 | LobHolder entity = new LobHolder();↵
|
12 | entity.setBlobLocator( Hibernate.createBlob( original ) );↵ | | 12 | entity.setClobLocator( Hibernate.createClob( original ) );↵
|
13 | s.save( entity );↵ | | 13 | s.save( entity );↵
|
14 | s.getTransaction().commit();↵ | | 14 | s.getTransaction().commit();↵
|
15 | s.close();↵ | | 15 | s.close();↵
|
|
16 | // load the entity with the clob locator, and close the session/transaction;↵ | | 16 | // load the entity with the clob locator, and close the session/transaction;↵
|
17 | // at that point it is unbounded...↵ | | 17 | // at that point it is unbounded...↵
|
18 | s = openSession();↵ | | 18 | s = openSession();↵
|
19 | s.beginTransaction();↵ | | 19 | s.beginTransaction();↵
|
20 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵ | | 20 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵
|
21 | s.getTransaction().commit();↵ | | 21 | s.getTransaction().commit();↵
|
22 | s.close();↵ | | 22 | s.close();↵
|
|
23 | assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );↵ | | 23 | assertEquals( CLOB_SIZE, entity.getClobLocator().length() );↵
|
24 | assertEquals( original, extractData( entity.getBlobLocator() ) );↵ | | 24 | assertEquals( original, extractData( entity.getClobLocator() ) );↵
|
|
25 | s = openSession();↵ | | 25 | s = openSession();↵
|
26 | s.beginTransaction();↵ | | 26 | s.beginTransaction();↵
|
27 | s.delete( entity );↵ | | 27 | s.delete( entity );↵
|
28 | s.getTransaction().commit();↵ | | 28 | s.getTransaction().commit();↵
|
29 | s.close();↵ | | 29 | s.close();↵
|
30 | | | 30 |
|