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); | ||||||||||||||||||||
6 | s.getTransaction().commit(); |
| 6 | s.connection().commit(); | ||||||||||||||||||||
7 | s.close(); |
| 7 | s.close(); | ||||||||||||||||||||
8 | modifyEntity(a); |
| 10 | assertTrue("polymorphic", foo instanceof BarProxy); | ||||||||||||||||||||
9 | s = openSession(); |
| | |||||||||||||||||||||
10 | s.beginTransaction(); | | ||||||||||||||||||||||
11 | A aLoaded = (A)s.load(A.class, new Long(a.getId())); | | ||||||||||||||||||||||
12 | assertTrue(aLoaded instanceof HibernateProxy); |
| 4 | bar.setBarString("bar bar"); | ||||||||||||||||||||
13 | assertSame(aLoaded, s.merge(a)); |
| 5 | s.flush(); | ||||||||||||||||||||
|
| 8 | s = openSession(); | |||||||||||||||||||||
| 9 | FooProxy foo = (FooProxy)s.load(Foo.class, bar.getKey()); | ||||||||||||||||||||||
| 12 | s.delete(foo); | ||||||||||||||||||||||
| 13 | s.flush(); | ||||||||||||||||||||||
14 | s.getTransaction().commit(); |
| 14 | s.connection().commit(); | ||||||||||||||||||||
15 | s.close(); |
| 15 | s.close(); | ||||||||||||||||||||
16 | verifyModifications(a.getId()); |
| 11 | assertTrue("subclass property", ((BarProxy)foo).getBarString().equals(bar.getBarString())); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.cascade.A of variable a does not match with type org.hibernate.test.legacy.Bar of variable bar |
2 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
3 | Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection() |
4 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
5 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
6 | Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized |
7 | Expression assertTrue("polymorphic",foo instanceof BarProxy) is a void method call, and thus it cannot be parameterized |
8 | Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized |
9 | Expression assertTrue("polymorphic",foo instanceof BarProxy) is a void method call, and thus it cannot be parameterized |
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 assertTrue(aLoaded instanceof HibernateProxy) is a void method call, and thus it cannot be parameterized |
12 | Expression bar.setBarString("bar bar") is a void method call, and thus it cannot be parameterized |
13 | Expression assertTrue(aLoaded instanceof HibernateProxy) is a void method call, and thus it cannot be parameterized |
14 | Expression bar.setBarString("bar bar") is a void method call, and thus it cannot be parameterized |
15 | Expression assertSame(aLoaded,s.merge(a)) is a void method call, and thus it cannot be parameterized |
16 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
17 | Expression assertSame(aLoaded,s.merge(a)) is a void method call, and thus it cannot be parameterized |
18 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
19 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection() |
21 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
22 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
23 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized |
25 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) is a void method call, and thus it cannot be parameterized |
26 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized |
28 | Expression assertTrue("subclass property",((BarProxy)foo).getBarString().equals(bar.getBarString())) is a void method call, and thus it cannot be parameterized |