File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java | |||
Method name: void testFetchInitializedCollection()
|
Method name: void testCollectionRefresh()
|
|||
Number of AST nodes: 24 | Number of AST nodes: 25 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | Baz baz = new Baz();↵ | 2 | ↵ | |
3 | Collection fooBag = new ArrayList();↵ | |||
4 | fooBag.add( new Foo() );↵ | |||
5 | fooBag↵ | 3 | Category c = new Category();↵ | |
4 | List list = new ArrayList();↵ | |||
5 | c.setSubcategories(list);↵ | |||
6 | .add( new Foo() );↵ | 6 | list.add( new Category() );↵ | |
7 | baz.setFooBag(fooBag);↵ | 7 | c.set↵ | |
8 | s.save(baz);↵ | |||
9 | s.flush();↵ | |||
10 | fooBag = baz.getFooBag();↵ | |||
11 | s.find("from Baz baz left join fetch baz.fooBag");↵ | |||
12 | assertTrue( fooBag==baz.getFooBag() ↵ | 8 | Name("root");↵ | |
9 | Serializable id = s.save(c);↵ | |||
13 | );↵ | 10 | s.flush();↵ | |
14 | s.connection().commit();↵ | 11 | s.connection().commit();↵ | |
15 | s.close();↵ | 12 | s.close();↵ | |
16 | s = openSession();↵ | 13 | s = openSession();↵ | |
17 | baz = (Baz) s.load( Baz.class, baz.getCode() );↵ | 14 | c = (Category) s.load(↵ | |
18 | Object bag = baz.getFooBag();↵ | |||
19 | assertFalse( Hibernate.isInitialized(bag) );↵ | |||
20 | s.find("from Baz baz left join fetch baz.fooBag");↵ | |||
21 | assertTrue( bag==baz.getFooBag() ↵ | 15 | Category.class, id);↵ | |
16 | s.refresh(c);↵ | |||
17 | s.flush();↵ | |||
18 | assertTrue( c.getSubcategories().size()==1 );↵ | |||
19 | s.flush();↵ | |||
20 | s.connection().commit();↵ | |||
21 | s.close();↵ | |||
22 | s = openSession();↵ | |||
22 | );↵ | 23 | c = (Category) s.load(Category.class, id);↵ | |
23 | assertTrue( baz.getFooBag().size()==2 );↵ | 24 | assertTrue( c.getSubcategories().size()==1 );↵ | |
24 | s.delete(baz);↵ | 25 | s.delete(c);↵ | |
25 | s.flush();↵ | 26 | s.flush();↵ | |
26 | s.connection().commit();↵ | 27 | s.connection().commit();↵ | |
27 | 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.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 362 |
Number of mapped statements | 12 |
Number of unmapped statements in the first code fragment | 12 |
Number of unmapped statements in the second code fragment | 13 |
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 | Category c = new Category(); | |||||||||||||||||||||||
2 | Baz baz = new Baz(); | | |||||||||||||||||||||||
3 | Collection fooBag = new ArrayList(); |
| 3 | List list = new ArrayList(); | |||||||||||||||||||||
|
| 4 | c.setSubcategories(list); | ||||||||||||||||||||||
4 | fooBag.add(new Foo()); |
| | ||||||||||||||||||||||
5 | fooBag.add(new Foo()); |
| 5 | list.add(new Category()); | |||||||||||||||||||||
|
| 6 | c.setName("root"); | ||||||||||||||||||||||
6 | baz.setFooBag(fooBag); |
| | ||||||||||||||||||||||
|
| 7 | Serializable id = s.save(c); | ||||||||||||||||||||||
7 | s.save(baz); |
| | ||||||||||||||||||||||
8 | s.flush(); | 8 | s.flush(); | ||||||||||||||||||||||
9 | fooBag = baz.getFooBag(); |
| | ||||||||||||||||||||||
10 | s.find("from Baz baz left join fetch baz.fooBag"); |
| | ||||||||||||||||||||||
11 | assertTrue(fooBag == baz.getFooBag()); | | |||||||||||||||||||||||
12 | s.connection().commit(); | 9 | s.connection().commit(); | ||||||||||||||||||||||
13 | s.close(); | 10 | s.close(); | ||||||||||||||||||||||
14 | s = openSession(); | 11 | s = openSession(); | ||||||||||||||||||||||
|
| 12 | c = (Category)s.load(Category.class, id); | ||||||||||||||||||||||
|
| 13 | s.refresh(c); | ||||||||||||||||||||||
|
| 14 | s.flush(); | ||||||||||||||||||||||
15 | baz = (Baz)s.load(Baz.class, baz.getCode()); |
| | ||||||||||||||||||||||
16 | Object bag = baz.getFooBag(); | | |||||||||||||||||||||||
17 | assertFalse(Hibernate.isInitialized(bag)); |
| 15 | assertTrue(c.getSubcategories().size() == 1); | |||||||||||||||||||||
|
| 17 | s.connection().commit(); | ||||||||||||||||||||||
|
| 18 | s.close(); | ||||||||||||||||||||||
18 | s.find("from Baz baz left join fetch baz.fooBag"); |
| | ||||||||||||||||||||||
|
| 19 | s = openSession(); | ||||||||||||||||||||||
19 | assertTrue(bag == baz.getFooBag()); | | |||||||||||||||||||||||
20 | assertTrue(baz.getFooBag().size() == 2); | | |||||||||||||||||||||||
21 | s.delete(baz); |
| 16 | s.flush(); | |||||||||||||||||||||
|
| 20 | c = (Category)s.load(Category.class, id); | ||||||||||||||||||||||
| 21 | assertTrue(c.getSubcategories().size() == 1); | |||||||||||||||||||||||
| 22 | s.delete(c); | |||||||||||||||||||||||
22 | s.flush(); | 23 | s.flush(); | ||||||||||||||||||||||
23 | s.connection().commit(); | 24 | s.connection().commit(); | ||||||||||||||||||||||
24 | s.close(); | 25 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement c.setSubcategories(list); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement fooBag.add(new Foo()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Type org.hibernate.test.legacy.Foo does not match with type org.hibernate.test.legacy.Category |
4 | Unmatched statement c.setName("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement baz.setFooBag(fooBag); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement Serializable id=s.save(c); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Unmatched statement fooBag=baz.getFooBag(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Unmatched statement s.find("from Baz baz left join fetch baz.fooBag"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Unmatched statement c=(Category)s.load(Category.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
11 | Unmatched statement s.refresh(c); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
13 | Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Expression Hibernate.isInitialized(bag) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression c.getSubcategories().size() == 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression assertFalse(Hibernate.isInitialized(bag)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression assertTrue(c.getSubcategories().size() == 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression assertFalse(Hibernate.isInitialized(bag)) is a void method call, and thus it cannot be parameterized |
19 | Expression assertTrue(c.getSubcategories().size() == 1) is a void method call, and thus it cannot be parameterized |
20 | Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
21 | Unmatched statement s.close(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
22 | Unmatched statement s.find("from Baz baz left join fetch baz.fooBag"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
23 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
24 | Expression s.delete(baz) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
26 | Expression s.delete(baz) is a void method call, and thus it cannot be parameterized |
27 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
28 | Expression s.delete(baz) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Expression s.delete(baz) is a void method call, and thus it cannot be parameterized |
31 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
32 | Unmatched statement c=(Category)s.load(Category.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
33 | Clone fragment #1 returns variables fooBag, s , while Clone fragment #2 returns variables list, s |