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 | 4 |
Number of unmapped statements in the first code fragment | 16 |
Number of unmapped statements in the second code fragment | 18 |
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 | ss.close(); | |||||||||||||||||||||||
7 | entity.setClobLocator(Hibernate.createClob(original)); |
| | ||||||||||||||||||||||
| 8 | ss = getSessions().openStatelessSession(); | |||||||||||||||||||||||
8 | s.save(entity); | | |||||||||||||||||||||||
|
| 9 | tx = ss.beginTransaction(); | ||||||||||||||||||||||
|
| 10 | Paper p2 = (Paper)ss.get(Paper.class, paper.getId()); | ||||||||||||||||||||||
9 | s.getTransaction().commit(); |
| 21 | tx.commit(); | |||||||||||||||||||||
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(); | |||||||||||||||||||||
| 14 | ss.close(); | |||||||||||||||||||||||
| 15 | ss = getSessions().openStatelessSession(); | |||||||||||||||||||||||
15 | s.close(); | | |||||||||||||||||||||||
|
| 16 | tx = ss.beginTransaction(); | ||||||||||||||||||||||
16 | assertEquals(CLOB_SIZE, entity.getClobLocator().length()); | | |||||||||||||||||||||||
| 17 | assertEquals("whtie", paper.getColor()); | |||||||||||||||||||||||
17 | assertEquals(original, extractData(entity.getClobLocator())); | | |||||||||||||||||||||||
| 18 | ss.refresh(paper); | |||||||||||||||||||||||
18 | s = openSession(); |
| | ||||||||||||||||||||||
| 19 | assertEquals("White", paper.getColor()); | |||||||||||||||||||||||
19 | s.beginTransaction(); | | |||||||||||||||||||||||
20 | s.delete(entity); |
| 20 | ss.delete(paper); | |||||||||||||||||||||
21 | s.getTransaction().commit(); |
| 6 | tx.commit(); | |||||||||||||||||||||
| 22 | ss.close(); | |||||||||||||||||||||||
22 | s.close(); | |
Row | Violation |
---|---|
1 | Unmatched statement Transaction tx=ss.beginTransaction(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement paper.setColor("whtie"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement Session s=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement entity.setClobLocator(Hibernate.createClob(original)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
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 Paper p2=(Paper)ss.get(Paper.class,paper.getId()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
7 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Unmatched statement p2.setColor("White"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
10 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
11 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | 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 |
14 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Type org.hibernate.test.lob.LobHolder of variable entity does not match with type org.hibernate.test.stateless.Paper of variable paper |
16 | Type org.hibernate.Session of variable s does not match with type org.hibernate.StatelessSession of variable ss |
17 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression tx cannot be parameterized, because it has dependencies to/from statements that will be extracted |