File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/cascade/MultiPathCascadeTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java | |||
Method name: void testMultiPathMergeModifiedDetachedIntoProxy()
|
Method name: void testPolymorphism()
|
|||
Number of AST nodes: 16 | Number of AST nodes: 15 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | s.beginTransaction();↵ | 2 | ↵ | |
3 | A a = new A(↵ | 3 | Bar bar = new Bar();↵ | |
4 | );↵ | 4 | s.save(bar);↵ | |
5 | a.setData( "Anna" );↵ | 5 | bar.set↵ | |
6 | s.save( a );↵ | |||
7 | s.getTransaction().commit();↵ | |||
8 | s.close();↵ | |||
9 | // modify detached entity↵ | |||
10 | modifyEntity( a );↵ | |||
11 | s = openSession();↵ | |||
12 | s.beginTransaction();↵ | |||
13 | A aLoaded = ( A ↵ | 6 | BarString("bar bar");↵ | |
7 | s.flush();↵ | |||
8 | s.connection().commit();↵ | |||
9 | s.close();↵ | |||
10 | s = openSession();↵ | |||
14 | ) s.load( A.class, new Long( a.getId() ) );↵ | 11 | FooProxy foo = (FooProxy) s.load( Foo.class, bar.getKey() );↵ | |
15 | assertTrue( aLoaded instanceof HibernateProxy );↵ | 12 | assertTrue( "polymorphic", foo instanceof BarProxy );↵ | |
16 | assertSame( aLoaded, s.merge( a ) );↵ | 13 | assert↵ | |
17 | s.getTransaction().commit();↵ | |||
18 | s.close(↵ | 14 | True( "subclass property", ( (BarProxy) foo ).getBarString().equals( bar.getBarString() ) );↵ | |
15 | //System.out.println( s.print(foo) );↵ | |||
19 | );↵ | 16 | s.delete(foo);↵ | |
20 | verifyModifications( a.getId() ↵ | 17 | s.flush();↵ | |
18 | s.connection().commit();↵ | |||
21 | ); | 19 | s.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 | 186 |
Number of mapped statements | 9 |
Number of unmapped statements in the first code fragment | 7 |
Number of unmapped statements in the second code fragment | 6 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); |
| 1 | Session s = openSession(); | ||||||||||||||||||||||||
| 2 | Bar bar = new Bar(); | ||||||||||||||||||||||||||
2 | s.beginTransaction(); |
| | |||||||||||||||||||||||||
3 | A a = new A(); |
| | |||||||||||||||||||||||||
4 | a.setData("Anna"); |
| | |||||||||||||||||||||||||
5 | s.save(a); |
| 3 | s.save(bar); | ||||||||||||||||||||||||
|
| 4 | bar.setBarString("bar bar"); | |||||||||||||||||||||||||
|
| 5 | s.flush(); | |||||||||||||||||||||||||
6 | s.getTransaction().commit(); |
| 6 | s.connection().commit(); | ||||||||||||||||||||||||
7 | s.close(); |
| 7 | s.close(); | ||||||||||||||||||||||||
8 | modifyEntity(a); |
| 11 | assertTrue("subclass property", ((BarProxy)foo).getBarString().equals(bar.getBarString())); | ||||||||||||||||||||||||
9 | s = openSession(); |
| 8 | s = openSession(); | ||||||||||||||||||||||||
|
| 9 | FooProxy foo = (FooProxy)s.load(Foo.class, bar.getKey()); | |||||||||||||||||||||||||
10 | s.beginTransaction(); |
| | |||||||||||||||||||||||||
11 | A aLoaded = (A)s.load(A.class, new Long(a.getId())); |
| | |||||||||||||||||||||||||
12 | assertTrue(aLoaded instanceof HibernateProxy); |
| 10 | assertTrue("polymorphic", foo instanceof BarProxy); | ||||||||||||||||||||||||
|
| 12 | s.delete(foo); | |||||||||||||||||||||||||
|
| 13 | s.flush(); | |||||||||||||||||||||||||
13 | assertSame(aLoaded, s.merge(a)); |
| | |||||||||||||||||||||||||
14 | s.getTransaction().commit(); |
| 14 | s.connection().commit(); | ||||||||||||||||||||||||
15 | s.close(); |
| 15 | s.close(); | ||||||||||||||||||||||||
16 | verifyModifications(a.getId()); | |
Row | Violation |
---|---|
1 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement A a=new A(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement a.setData("Anna"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Type org.hibernate.test.cascade.A of variable a does not match with type org.hibernate.test.legacy.Bar of variable bar |
5 | Unmatched statement bar.setBarString("bar bar"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/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 s.connection() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection() |
10 | Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized |
13 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) is a void method call, and thus it cannot be parameterized |
14 | Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized |
17 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) is a void method call, and thus it cannot be parameterized |
18 | Unmatched statement FooProxy foo=(FooProxy)s.load(Foo.class,bar.getKey()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Unmatched statement A aLoaded=(A)s.load(A.class,new Long(a.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
21 | Expression assertTrue(aLoaded instanceof HibernateProxy) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression assertTrue("polymorphic",foo instanceof BarProxy) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
23 | Expression assertTrue(aLoaded instanceof HibernateProxy) is a void method call, and thus it cannot be parameterized |
24 | Expression assertTrue("polymorphic",foo instanceof BarProxy) is a void method call, and thus it cannot be parameterized |
25 | Unmatched statement s.delete(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
26 | Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
27 | Unmatched statement assertSame(aLoaded,s.merge(a)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
28 | Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression s.connection() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection() |
31 | Clone fragment #1 returns variable s with type org.hibernate.Session , while Clone fragment #2 returns variable s with type org.hibernate.classic.Session |