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: void testBoundedBlobLocatorAccess()
|
Method name: void testBoundedClobLocatorAccess()
|
|||
Number of AST nodes: 51 | Number of AST nodes: 51 | |||
1 | byte[] original = buildRecursively( BLOB_SIZE, true );↵ | 1 | String original = buildRecursively( CLOB_SIZE, 'x' );↵ | |
2 | byte[] changed = buildRecursively( BLOB_SIZE, false );↵ | 2 | String changed = buildRecursively( CLOB_SIZE, 'y' );↵ | |
3 | Session s = openSession();↵ | 3 | Session s = openSession();↵ | |
4 | s.beginTransaction();↵ | 4 | s.beginTransaction();↵ | |
5 | LobHolder entity = new LobHolder();↵ | 5 | LobHolder entity = new LobHolder();↵ | |
6 | entity.setBlobLocator( Hibernate.createBlob( original ) );↵ | 6 | entity.setClobLocator( Hibernate.createClob( original ) );↵ | |
7 | s.save( entity );↵ | 7 | s.save( entity );↵ | |
8 | s.getTransaction().commit();↵ | 8 | s.getTransaction().commit();↵ | |
9 | s.close();↵ | 9 | s.close();↵ | |
10 | s = openSession();↵ | 10 | s = openSession();↵ | |
11 | s.beginTransaction();↵ | 11 | s.beginTransaction();↵ | |
12 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵ | 12 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵ | |
13 | assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );↵ | 13 | assertEquals( CLOB_SIZE, entity.getClobLocator().length() );↵ | |
14 | assertEquals( original, extractData( entity.getBlobLocator() ) );↵ | 14 | assertEquals( original, extractData( entity.getClobLocator() ) );↵ | |
15 | s.getTransaction().commit();↵ | 15 | s.getTransaction().commit();↵ | |
16 | s.close();↵ | 16 | s.close();↵ | |
17 | // test mutation via setting the new clob data...↵ | 17 | // test mutation via setting the new clob data...↵ | |
18 | if ( supportsLobValueChangePropogation() ) {↵ | 18 | if ( supportsLobValueChangePropogation() ) {↵ | |
19 | s = openSession();↵ | 19 | s = openSession();↵ | |
20 | s.beginTransaction();↵ | 20 | s.beginTransaction();↵ | |
21 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );↵ | 21 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );↵ | |
22 | entity.getBlobLocator().truncate( 1 );↵ | 22 | entity.getClobLocator().truncate( 1 );↵ | |
23 | entity.getBlobLocator().setBytes( 1, changed );↵ | 23 | entity.getClobLocator().setString( 1, changed );↵ | |
24 | s.getTransaction().commit();↵ | 24 | s.getTransaction().commit();↵ | |
25 | s.close();↵ | 25 | s.close();↵ | |
26 | s = openSession();↵ | 26 | s = openSession();↵ | |
27 | s.beginTransaction();↵ | 27 | s.beginTransaction();↵ | |
28 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );↵ | 28 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );↵ | |
29 | assertNotNull( entity.getBlobLocator() );↵ | 29 | assertNotNull( entity.getClobLocator() );↵ | |
30 | assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );↵ | 30 | assertEquals( CLOB_SIZE, entity.getClobLocator().length() );↵ | |
31 | assertEquals( changed, extractData( entity.getBlobLocator() ) );↵ | 31 | assertEquals( changed, extractData( entity.getClobLocator() ) );↵ | |
32 | entity.getBlobLocator().truncate( 1 );↵ | 32 | entity.getClobLocator().truncate( 1 );↵ | |
33 | entity.getBlobLocator().setBytes( 1, original );↵ | 33 | entity.getClobLocator().setString( 1, original );↵ | |
34 | s.getTransaction().commit();↵ | 34 | s.getTransaction().commit();↵ | |
35 | s.close();↵ | 35 | s.close();↵ | |
36 | }↵ | 36 | }↵ | |
37 | // test mutation via supplying a new clob locator instance...↵ | 37 | // test mutation via supplying a new clob locator instance...↵ | |
38 | s = openSession();↵ | 38 | s = openSession();↵ | |
39 | s.beginTransaction();↵ | 39 | s.beginTransaction();↵ | |
40 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );↵ | 40 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );↵ | |
41 | assertNotNull( entity.getBlobLocator() );↵ | 41 | assertNotNull( entity.getClobLocator() );↵ | |
42 | assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );↵ | 42 | assertEquals( CLOB_SIZE, entity.getClobLocator().length() );↵ | |
43 | assertEquals( original, extractData( entity.getBlobLocator() ) );↵ | 43 | assertEquals( original, extractData( entity.getClobLocator() ) );↵ | |
44 | entity.setBlobLocator( Hibernate.createBlob( changed ) );↵ | 44 | entity.setClobLocator( Hibernate.createClob( changed ) );↵ | |
45 | s.getTransaction().commit();↵ | 45 | s.getTransaction().commit();↵ | |
46 | s.close();↵ | 46 | s.close();↵ | |
47 | s = openSession();↵ | 47 | s = openSession();↵ | |
48 | s.beginTransaction();↵ | 48 | s.beginTransaction();↵ | |
49 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵ | 49 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵ | |
50 | assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );↵ | 50 | assertEquals( CLOB_SIZE, entity.getClobLocator().length() );↵ | |
51 | assertEquals( changed, extractData( entity.getBlobLocator() ) );↵ | 51 | assertEquals( changed, extractData( entity.getClobLocator() ) );↵ | |
52 | s.delete( entity );↵ | 52 | s.delete( entity );↵ | |
53 | s.getTransaction().commit();↵ | 53 | s.getTransaction().commit();↵ | |
54 | s.close(); | 54 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 563 |
Number of mapped statements | 49 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 79.6 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | String original = buildRecursively(CLOB_SIZE, 'x'); | |||||||||||||||||||||||||||
1 | byte[] original = buildRecursively(BLOB_SIZE, true); | | |||||||||||||||||||||||||||
| 2 | String changed = buildRecursively(CLOB_SIZE, 'y'); | |||||||||||||||||||||||||||
2 | byte[] changed = buildRecursively(BLOB_SIZE, false); | | |||||||||||||||||||||||||||
3 | Session s = openSession(); | 3 | Session s = openSession(); | ||||||||||||||||||||||||||
4 | s.beginTransaction(); | 4 | s.beginTransaction(); | ||||||||||||||||||||||||||
5 | LobHolder entity = new LobHolder(); | 5 | LobHolder entity = new LobHolder(); | ||||||||||||||||||||||||||
6 | entity.setBlobLocator(Hibernate.createBlob(original)); |
| 6 | entity.setClobLocator(Hibernate.createClob(original)); | |||||||||||||||||||||||||
7 | s.save(entity); | 7 | s.save(entity); | ||||||||||||||||||||||||||
8 | s.getTransaction().commit(); | 8 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
9 | s.close(); | 9 | s.close(); | ||||||||||||||||||||||||||
10 | s = openSession(); | 10 | s = openSession(); | ||||||||||||||||||||||||||
11 | s.beginTransaction(); | 11 | s.beginTransaction(); | ||||||||||||||||||||||||||
12 | entity = (LobHolder)s.get(LobHolder.class, entity.getId()); | 12 | entity = (LobHolder)s.get(LobHolder.class, entity.getId()); | ||||||||||||||||||||||||||
13 | assertEquals(BLOB_SIZE, entity.getBlobLocator().length()); |
| 14 | assertEquals(original, extractData(entity.getClobLocator())); | |||||||||||||||||||||||||
14 | assertEquals(original, extractData(entity.getBlobLocator())); |
| 40 | assertEquals(original, extractData(entity.getClobLocator())); | |||||||||||||||||||||||||
15 | s.getTransaction().commit(); | 15 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
16 | s.close(); | 16 | s.close(); | ||||||||||||||||||||||||||
17 | if (supportsLobValueChangePropogation()) | 17 | if (supportsLobValueChangePropogation()) | ||||||||||||||||||||||||||
18 | s = openSession(); | 18 | s = openSession(); | ||||||||||||||||||||||||||
19 | s.beginTransaction(); | 19 | s.beginTransaction(); | ||||||||||||||||||||||||||
20 | entity = (LobHolder)s.get(LobHolder.class, entity.getId(), LockMode.UPGRADE); | 20 | entity = (LobHolder)s.get(LobHolder.class, entity.getId(), LockMode.UPGRADE); | ||||||||||||||||||||||||||
21 | entity.getBlobLocator().truncate(1); |
| 21 | entity.getClobLocator().truncate(1); | |||||||||||||||||||||||||
22 | entity.getBlobLocator().setBytes(1, changed); |
| 22 | entity.getClobLocator().setString(1, changed); | |||||||||||||||||||||||||
23 | s.getTransaction().commit(); | 23 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
24 | s.close(); | 24 | s.close(); | ||||||||||||||||||||||||||
25 | s = openSession(); | 25 | s = openSession(); | ||||||||||||||||||||||||||
26 | s.beginTransaction(); | 26 | s.beginTransaction(); | ||||||||||||||||||||||||||
27 | entity = (LobHolder)s.get(LobHolder.class, entity.getId(), LockMode.UPGRADE); | 27 | entity = (LobHolder)s.get(LobHolder.class, entity.getId(), LockMode.UPGRADE); | ||||||||||||||||||||||||||
28 | assertNotNull(entity.getBlobLocator()); |
| 28 | assertNotNull(entity.getClobLocator()); | |||||||||||||||||||||||||
29 | assertEquals(BLOB_SIZE, entity.getBlobLocator().length()); |
| 30 | assertEquals(changed, extractData(entity.getClobLocator())); | |||||||||||||||||||||||||
30 | assertEquals(changed, extractData(entity.getBlobLocator())); |
| 29 | assertEquals(CLOB_SIZE, entity.getClobLocator().length()); | |||||||||||||||||||||||||
31 | entity.getBlobLocator().truncate(1); |
| 31 | entity.getClobLocator().truncate(1); | |||||||||||||||||||||||||
32 | entity.getBlobLocator().setBytes(1, original); |
| 32 | entity.getClobLocator().setString(1, original); | |||||||||||||||||||||||||
33 | s.getTransaction().commit(); | 33 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
34 | s.close(); | 34 | s.close(); | ||||||||||||||||||||||||||
35 | s = openSession(); | 35 | s = openSession(); | ||||||||||||||||||||||||||
36 | s.beginTransaction(); | 36 | s.beginTransaction(); | ||||||||||||||||||||||||||
37 | entity = (LobHolder)s.get(LobHolder.class, entity.getId(), LockMode.UPGRADE); | 37 | entity = (LobHolder)s.get(LobHolder.class, entity.getId(), LockMode.UPGRADE); | ||||||||||||||||||||||||||
38 | assertNotNull(entity.getBlobLocator()); |
| 38 | assertNotNull(entity.getClobLocator()); | |||||||||||||||||||||||||
39 | assertEquals(BLOB_SIZE, entity.getBlobLocator().length()); |
| 48 | assertEquals(changed, extractData(entity.getClobLocator())); | |||||||||||||||||||||||||
40 | assertEquals(original, extractData(entity.getBlobLocator())); |
| 39 | assertEquals(CLOB_SIZE, entity.getClobLocator().length()); | |||||||||||||||||||||||||
41 | entity.setBlobLocator(Hibernate.createBlob(changed)); |
| 41 | entity.setClobLocator(Hibernate.createClob(changed)); | |||||||||||||||||||||||||
42 | s.getTransaction().commit(); | 42 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
43 | s.close(); | 43 | s.close(); | ||||||||||||||||||||||||||
44 | s = openSession(); | 44 | s = openSession(); | ||||||||||||||||||||||||||
45 | s.beginTransaction(); | 45 | s.beginTransaction(); | ||||||||||||||||||||||||||
46 | entity = (LobHolder)s.get(LobHolder.class, entity.getId()); | 46 | entity = (LobHolder)s.get(LobHolder.class, entity.getId()); | ||||||||||||||||||||||||||
47 | assertEquals(BLOB_SIZE, entity.getBlobLocator().length()); |
| 49 | s.delete(entity); | |||||||||||||||||||||||||
48 | assertEquals(changed, extractData(entity.getBlobLocator())); |
| 47 | assertEquals(CLOB_SIZE, entity.getClobLocator().length()); | |||||||||||||||||||||||||
49 | s.delete(entity); |
| 13 | assertEquals(CLOB_SIZE, entity.getClobLocator().length()); | |||||||||||||||||||||||||
50 | s.getTransaction().commit(); | 50 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
51 | s.close(); | 51 | s.close(); |
Row | Violation |
---|---|
1 | Expression entity.setBlobLocator(Hibernate.createBlob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression entity.setClobLocator(Hibernate.createClob(original)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression entity.setBlobLocator(Hibernate.createBlob(original)) is a void method call, and thus it cannot be parameterized |
4 | Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized |
5 | Type java.sql.Blob of variable Hibernate.createBlob(original) does not match with type java.sql.Clob of variable Hibernate.createClob(original) |
6 | Type byte[] of variable original does not match with type java.lang.String of variable original |
7 | Type int of variable BLOB_SIZE does not match with type java.lang.String of variable original |
8 | Type byte[] of variable original does not match with type java.lang.String of variable original |
9 | Expression entity.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator() |
12 | Expression entity.getBlobLocator().setBytes(1,changed) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression entity.getClobLocator().setString(1,changed) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Type byte[] of variable changed does not match with type java.lang.String of variable changed |
15 | Expression entity.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator() |
18 | Expression entity.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator() |
21 | Type int of variable BLOB_SIZE does not match with type java.lang.String of variable changed |
22 | Type byte[] of variable changed does not match with type int of variable CLOB_SIZE |
23 | Expression entity.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator() |
26 | Expression entity.getBlobLocator().setBytes(1,original) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression entity.getClobLocator().setString(1,original) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Type byte[] of variable original does not match with type java.lang.String of variable original |
29 | Expression entity.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
31 | Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator() |
32 | Expression entity.getBlobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
33 | Expression entity.getClobLocator() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
34 | Type java.sql.Blob of variable entity.getBlobLocator() does not match with type java.sql.Clob of variable entity.getClobLocator() |
35 | Type int of variable BLOB_SIZE does not match with type java.lang.String of variable changed |
36 | Type byte[] of variable original does not match with type int of variable CLOB_SIZE |
37 | Expression entity.setBlobLocator(Hibernate.createBlob(changed)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
38 | Expression entity.setClobLocator(Hibernate.createClob(changed)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
39 | Expression entity.setBlobLocator(Hibernate.createBlob(changed)) is a void method call, and thus it cannot be parameterized |
40 | Expression entity.setClobLocator(Hibernate.createClob(changed)) is a void method call, and thus it cannot be parameterized |
41 | Type java.sql.Blob of variable Hibernate.createBlob(changed) does not match with type java.sql.Clob of variable Hibernate.createClob(changed) |
42 | Type byte[] of variable changed does not match with type java.lang.String of variable changed |
43 | Expression assertEquals(BLOB_SIZE,entity.getBlobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
44 | Expression s.delete(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
45 | Expression assertEquals(BLOB_SIZE,entity.getBlobLocator().length()) is a void method call, and thus it cannot be parameterized |
46 | Expression s.delete(entity) is a void method call, and thus it cannot be parameterized |
47 | Expression assertEquals(BLOB_SIZE,entity.getBlobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
48 | Expression s.delete(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
49 | Expression assertEquals(BLOB_SIZE,entity.getBlobLocator().length()) is a void method call, and thus it cannot be parameterized |
50 | Expression s.delete(entity) is a void method call, and thus it cannot be parameterized |
51 | Type byte[] of variable changed does not match with type int of variable CLOB_SIZE |
52 | Expression s.delete(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
53 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
54 | Expression s.delete(entity) is a void method call, and thus it cannot be parameterized |
55 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized |
56 | Expression s.delete(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
57 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
58 | Expression s.delete(entity) is a void method call, and thus it cannot be parameterized |
59 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized |