File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lob/ClobTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/stateless/StatelessSessionTest.java | |||
Method name: void testUnboundedClobLocatorAccess()
|
Method name: void testRefresh()
|
|||
Number of AST nodes: 22 | Number of AST nodes: 22 | |||
1 | if ( ! supportsUnboundedLobLocatorMaterialization() ) {↵ | |||
2 | return;↵ | |||
3 | }↵ | |||
4 | // Note: unbounded mutation of the underlying lob data is completely↵ | |||
5 | // unsupported; most databases would not allow such a construct anyway.↵ | |||
6 | // Thus here we are only testing materialization...↵ | |||
7 | String original = buildRecursively( CLOB_SIZE, 'x' );↵ | |||
8 | Session s = openSession();↵ | |||
9 | ↵ | 1 | StatelessSession ss = getSessions().openStatelessSession();↵ | |
10 | s.beginTransaction(); ↵ | 2 | Transaction tx = ss.beginTransaction();↵ | |
11 | LobHolder entity = new LobHolder(); ↵ | 3 | Paper paper = new Paper();↵ | |
12 | entity.setClobLocator( Hibernate.createClob( original ) ); ↵ | 4 | paper.setColor( "whtie" );↵ | |
13 | s.save( entity ); ↵ | 5 | ss.insert( paper );↵ | |
14 | s.getTransaction().commit(); ↵ | 6 | tx.commit();↵ | |
15 | s.close();↵ | 7 | ss.close();↵ | |
16 | // load the entity with the clob locator, and close the session/transaction;↵ | |||
17 | // at that point it is unbounded...↵ | |||
18 | s = open↵ | |||
19 | Session(); ↵ | 8 | ss = getSessions().openStatelessSession();↵ | |
20 | s.beginTransaction(); ↵ | 9 | tx = ss.beginTransaction();↵ | |
21 | entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() ); ↵ | 10 | Paper p2 = ( Paper ) ss.get( Paper.class, paper.getId() );↵ | |
22 | s.getTransaction()↵ | 11 | p2.setColor( "White" );↵ | |
12 | ss.update( p2 );↵ | |||
23 | .commit(); ↵ | 13 | tx.commit();↵ | |
24 | s.close();↵ | 14 | ss.close();↵ | |
25 | ↵ | |||
26 | assertEquals( CLOB_SIZE, entity.getClobLocator().length() ↵ | 15 | ss = getSessions().openStatelessSession();↵ | |
27 | ); ↵ | 16 | tx = ss.beginTransaction();↵ | |
28 | assertEquals( original, extractData( entity.getClobLocator() ) );↵ | 17 | assertEquals( "whtie", paper.getColor() );↵ | |
29 | ↵ | |||
30 | s = openSession(); ↵ | 18 | ss.refresh( paper );↵ | |
31 | s.beginTransaction(); ↵ | 19 | assertEquals( "White", paper.getColor() );↵ | |
32 | s.delete( entity ); ↵ | 20 | ss.delete( paper );↵ | |
33 | s.getTransaction().commit(); ↵ | 21 | tx.commit();↵ | |
34 | s.close(); | 22 | ss.close(); | |
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.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 440 |
Number of mapped statements | 7 |
Number of unmapped statements in the first code fragment | 13 |
Number of unmapped statements in the second code fragment | 15 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | StatelessSession ss = getSessions().openStatelessSession(); | ||||||||||||||||||||||||
| 2 | Transaction tx = ss.beginTransaction(); | ||||||||||||||||||||||||
| 3 | Paper paper = new Paper(); | ||||||||||||||||||||||||
3 | String original = buildRecursively(CLOB_SIZE, 'x'); | | ||||||||||||||||||||||||
| 4 | paper.setColor("whtie"); | ||||||||||||||||||||||||
4 | Session s = openSession(); | | ||||||||||||||||||||||||
| 5 | ss.insert(paper); | ||||||||||||||||||||||||
5 | s.beginTransaction(); | | ||||||||||||||||||||||||
6 | LobHolder entity = new LobHolder(); | | ||||||||||||||||||||||||
7 | entity.setClobLocator(Hibernate.createClob(original)); |
| 17 | assertEquals("whtie", paper.getColor()); | ||||||||||||||||||||||
8 | s.save(entity); | | ||||||||||||||||||||||||
9 | s.getTransaction().commit(); |
| 6 | tx.commit(); | ||||||||||||||||||||||
| 7 | ss.close(); | ||||||||||||||||||||||||
| 8 | ss = getSessions().openStatelessSession(); | ||||||||||||||||||||||||
|
| 9 | tx = ss.beginTransaction(); | |||||||||||||||||||||||
| 10 | Paper p2 = (Paper)ss.get(Paper.class, paper.getId()); | ||||||||||||||||||||||||
10 | s.close(); | | ||||||||||||||||||||||||
| 11 | p2.setColor("White"); | ||||||||||||||||||||||||
11 | s = openSession(); |
| | |||||||||||||||||||||||
| 12 | ss.update(p2); | ||||||||||||||||||||||||
12 | s.beginTransaction(); | | ||||||||||||||||||||||||
13 | entity = (LobHolder)s.get(LobHolder.class, entity.getId()); |
| | |||||||||||||||||||||||
14 | s.getTransaction().commit(); |
| 13 | tx.commit(); | ||||||||||||||||||||||
15 | s.close(); | | ||||||||||||||||||||||||
16 | assertEquals(CLOB_SIZE, entity.getClobLocator().length()); |
| 14 | ss.close(); | ||||||||||||||||||||||
|
| 15 | ss = getSessions().openStatelessSession(); | |||||||||||||||||||||||
|
| 16 | tx = ss.beginTransaction(); | |||||||||||||||||||||||
| 18 | ss.refresh(paper); | ||||||||||||||||||||||||
17 | assertEquals(original, extractData(entity.getClobLocator())); |
| 22 | ss.close(); | ||||||||||||||||||||||
18 | s = openSession(); |
| | |||||||||||||||||||||||
| 19 | assertEquals("White", paper.getColor()); | ||||||||||||||||||||||||
19 | s.beginTransaction(); | | ||||||||||||||||||||||||
20 | s.delete(entity); |
| 20 | ss.delete(paper); | ||||||||||||||||||||||
21 | s.getTransaction().commit(); |
| 21 | tx.commit(); | ||||||||||||||||||||||
22 | s.close(); | |
Row | Violation |
---|---|
1 | Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized |
2 | Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized |
3 | Expression entity.setClobLocator(Hibernate.createClob(original)) is a void method call, and thus it cannot be parameterized |
4 | Expression assertEquals("whtie",paper.getColor()) is a void method call, and thus it cannot be parameterized |
5 | Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement entity=(LobHolder)s.get(LobHolder.class,entity.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized |
10 | Expression ss.close() is a void method call, and thus it cannot be parameterized |
11 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression assertEquals(CLOB_SIZE,entity.getClobLocator().length()) is a void method call, and thus it cannot be parameterized |
13 | Expression ss.close() is a void method call, and thus it cannot be parameterized |
14 | Unmatched statement ss=getSessions().openStatelessSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Unmatched statement tx=ss.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Expression assertEquals(original,extractData(entity.getClobLocator())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression assertEquals(original,extractData(entity.getClobLocator())) is a void method call, and thus it cannot be parameterized |
18 | Expression ss.close() is a void method call, and thus it cannot be parameterized |
19 | Expression assertEquals(original,extractData(entity.getClobLocator())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression assertEquals(original,extractData(entity.getClobLocator())) is a void method call, and thus it cannot be parameterized |
21 | Expression ss.close() is a void method call, and thus it cannot be parameterized |
22 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
23 | Type org.hibernate.test.lob.LobHolder of variable entity does not match with type org.hibernate.test.stateless.Paper of variable paper |
24 | Type org.hibernate.Session of variable s does not match with type org.hibernate.StatelessSession of variable ss |