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 testUnboundedBlobLocatorAccess()
|
Method name: void testUnboundedClobLocatorAccess()
|
|||
Number of AST nodes: 22 | Number of AST nodes: 22 | |||
1 | if ( ! supportsUnboundedLobLocatorMaterialization() ) {↵ | 1 | if ( ! supportsUnboundedLobLocatorMaterialization() ) {↵ | |
2 | return;↵ | 2 | return;↵ | |
3 | }↵ | 3 | }↵ | |
4 | // Note: unbounded mutation of the underlying lob data is completely↵ | 4 | // Note: unbounded mutation of the underlying lob data is completely↵ | |
5 | // unsupported; most databases would not allow such a construct anyway.↵ | 5 | // unsupported; most databases would not allow such a construct anyway.↵ | |
6 | // Thus here we are only testing materialization...↵ | 6 | // Thus here we are only testing materialization...↵ | |
7 | byte[] original = buildRecursively( BLOB_SIZE, true );↵ | 7 | String original = buildRecursively( CLOB_SIZE, 'x' );↵ | |
8 | Session s = openSession();↵ | 8 | Session s = openSession();↵ | |
9 | s.beginTransaction();↵ | 9 | s.beginTransaction();↵ | |
10 | LobHolder entity = new LobHolder();↵ | 10 | LobHolder entity = new LobHolder();↵ | |
11 | entity.setBlobLocator( Hibernate.createBlob( original ) );↵ | 11 | entity.setClobLocator( Hibernate.createClob( original ) );↵ | |
12 | s.save( entity );↵ | 12 | s.save( entity );↵ | |
13 | s.getTransaction().commit();↵ | 13 | s.getTransaction().commit();↵ | |
14 | s.close();↵ | 14 | s.close();↵ | |
15 | // load the entity with the clob locator, and close the session/transaction;↵ | 15 | // load the entity with the clob locator, and close the session/transaction;↵ | |
16 | // at that point it is unbounded...↵ | 16 | // at that point it is unbounded...↵ | |
17 | s = openSession();↵ | 17 | s = openSession();↵ | |
18 | s.beginTransaction();↵ | 18 | s.beginTransaction();↵ | |
19 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵ | 19 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );↵ | |
20 | s.getTransaction().commit();↵ | 20 | s.getTransaction().commit();↵ | |
21 | s.close();↵ | 21 | s.close();↵ | |
22 | assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );↵ | 22 | assertEquals( CLOB_SIZE, entity.getClobLocator().length() );↵ | |
23 | assertEquals( original, extractData( entity.getBlobLocator() ) );↵ | 23 | assertEquals( original, extractData( entity.getClobLocator() ) );↵ | |
24 | s = openSession();↵ | 24 | s = openSession();↵ | |
25 | s.beginTransaction();↵ | 25 | s.beginTransaction();↵ | |
26 | s.delete( entity );↵ | 26 | s.delete( entity );↵ | |
27 | s.getTransaction().commit();↵ | 27 | s.getTransaction().commit();↵ | |
28 | s.close(); | 28 |
| |
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 | 88 |
Number of mapped statements | 21 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 4.9 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | if (!supportsUnboundedLobLocatorMaterialization()) | 1 | if (!supportsUnboundedLobLocatorMaterialization()) | ||||||||||||||||||||||||||
2 | return; | 2 | return; | ||||||||||||||||||||||||||
| 3 | String original = buildRecursively(CLOB_SIZE, 'x'); | |||||||||||||||||||||||||||
3 | byte[] original = buildRecursively(BLOB_SIZE, true); | | |||||||||||||||||||||||||||
4 | Session s = openSession(); | 4 | Session s = openSession(); | ||||||||||||||||||||||||||
5 | s.beginTransaction(); | 5 | s.beginTransaction(); | ||||||||||||||||||||||||||
6 | LobHolder entity = new LobHolder(); | 6 | LobHolder entity = new LobHolder(); | ||||||||||||||||||||||||||
7 | entity.setBlobLocator(Hibernate.createBlob(original)); |
| 7 | entity.setClobLocator(Hibernate.createClob(original)); | |||||||||||||||||||||||||
8 | s.save(entity); | 8 | s.save(entity); | ||||||||||||||||||||||||||
9 | s.getTransaction().commit(); | 9 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
10 | s.close(); | 10 | s.close(); | ||||||||||||||||||||||||||
11 | s = openSession(); | 11 | s = openSession(); | ||||||||||||||||||||||||||
12 | s.beginTransaction(); | 12 | s.beginTransaction(); | ||||||||||||||||||||||||||
13 | entity = (LobHolder)s.get(LobHolder.class, entity.getId()); | 13 | entity = (LobHolder)s.get(LobHolder.class, entity.getId()); | ||||||||||||||||||||||||||
14 | s.getTransaction().commit(); | 14 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
15 | s.close(); | 15 | s.close(); | ||||||||||||||||||||||||||
16 | assertEquals(BLOB_SIZE, entity.getBlobLocator().length()); |
| 17 | assertEquals(original, extractData(entity.getClobLocator())); | |||||||||||||||||||||||||
17 | assertEquals(original, extractData(entity.getBlobLocator())); |
| 16 | assertEquals(CLOB_SIZE, entity.getClobLocator().length()); | |||||||||||||||||||||||||
18 | s = openSession(); | 18 | s = openSession(); | ||||||||||||||||||||||||||
19 | s.beginTransaction(); | 19 | s.beginTransaction(); | ||||||||||||||||||||||||||
20 | s.delete(entity); | 20 | s.delete(entity); | ||||||||||||||||||||||||||
21 | s.getTransaction().commit(); | 21 | s.getTransaction().commit(); | ||||||||||||||||||||||||||
22 | s.close(); | 22 | 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 int of variable CLOB_SIZE |