public void testUnboundedBlobLocatorAccess() throws Throwable { if ( ! supportsUnboundedLobLocatorMaterialization() ) { return; } // 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... byte[] original = buildRecursively( BLOB_SIZE, true ); Session s = openSession(); s.beginTransaction(); LobHolder entity = new LobHolder(); entity.setBlobLocator( Hibernate.createBlob( 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 = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); s.getTransaction().commit(); s.close(); assertEquals( BLOB_SIZE, entity.getBlobLocator().length() ); assertEquals( original, extractData( entity.getBlobLocator() ) ); s = openSession(); s.beginTransaction(); s.delete( entity ); s.getTransaction().commit(); s.close();
public void testUnboundedClobLocatorAccess() throws Throwable { if ( ! supportsUnboundedLobLocatorMaterialization() ) { return; } // 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 = buildRecursively( CLOB_SIZE, 'x' ); Session s = openSession(); s.beginTransaction(); LobHolder entity = new LobHolder(); entity.setClobLocator( Hibernate.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 = ( LobHolder ) 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();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lob/BlobTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lob/ClobTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
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
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0