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 | 13 |
Number of unmapped statements in the first code fragment | 11 |
Number of unmapped statements in the second code fragment | 12 |
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 | List list = new ArrayList(); | ||||||||||||||||||||||||
3 | Collection fooBag = new ArrayList(); | | ||||||||||||||||||||||||
| 4 | c.setSubcategories(list); | ||||||||||||||||||||||||
4 | fooBag.add(new Foo()); |
| 5 | list.add(new Category()); | ||||||||||||||||||||||
5 | fooBag.add(new Foo()); | | ||||||||||||||||||||||||
| 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()); |
| 14 | s.flush(); | ||||||||||||||||||||||
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); | ||||||||||||||||||||||||
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); | ||||||||||||||||||||||
18 | s.find("from Baz baz left join fetch baz.fooBag"); | | ||||||||||||||||||||||||
19 | assertTrue(bag == baz.getFooBag()); |
| 17 | s.connection().commit(); | ||||||||||||||||||||||
20 | assertTrue(baz.getFooBag().size() == 2); | | ||||||||||||||||||||||||
21 | s.delete(baz); |
| 16 | s.flush(); | ||||||||||||||||||||||
| 18 | s.close(); | ||||||||||||||||||||||||
|
| 19 | s = openSession(); | |||||||||||||||||||||||
|
| 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 | Type org.hibernate.test.legacy.Foo of variable new Foo() does not match with type org.hibernate.test.legacy.Category of variable new Category() |
2 | Type java.util.Collection of variable fooBag does not match with type java.util.List of variable list |
3 | 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 |
4 | 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 |
5 | 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 |
6 | 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 |
7 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression assertTrue(fooBag == baz.getFooBag()) is a void method call, and thus it cannot be parameterized |
9 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
10 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression assertTrue(fooBag == baz.getFooBag()) is a void method call, and thus it cannot be parameterized |
12 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
13 | 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 |
14 | 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 |
15 | Expression assertFalse(Hibernate.isInitialized(bag)) is a void method call, and thus it cannot be parameterized |
16 | Expression assertTrue(c.getSubcategories().size() == 1) is a void method call, and thus it cannot be parameterized |
17 | Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression assertTrue(bag == baz.getFooBag()) is a void method call, and thus it cannot be parameterized |
19 | Expression s.connection().commit() is a void method call, and thus it cannot be parameterized |
20 | Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression assertTrue(bag == baz.getFooBag()) is a void method call, and thus it cannot be parameterized |
22 | Expression s.connection().commit() is a void method call, and thus it cannot be parameterized |
23 | Expression s.delete(baz) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression s.delete(baz) is a void method call, and thus it cannot be parameterized |
26 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
27 | Expression s.delete(baz) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression s.delete(baz) is a void method call, and thus it cannot be parameterized |
30 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
31 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
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 |