File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/set/PersistentSetTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/set/PersistentSetTest.java | |||
Method name: void testCompositeElementCollectionDirtyCheckingFailureExpected()
|
Method name: void testCompositeElementMergingFailureExpected()
|
|||
Number of AST nodes: 27 | Number of AST nodes: 27 | |||
1 | Session session = openSession();↵ | 1 | Session session = openSession();↵ | |
2 | session.beginTransaction();↵ | 2 | session.beginTransaction();↵ | |
3 | Container container = new Container( "p1" );↵ | 3 | Container container = new Container( "p1" );↵ | |
4 | Container.Content c1 = new Container.Content( "c1" );↵ | 4 | Container.Content c1 = new Container.Content( "c1" );↵ | |
5 | container.getContents().add( c1 );↵ | 5 | container.getContents().add( c1 );↵ | |
6 | session.save( container );↵ | 6 | session.save( container );↵ | |
7 | session.getTransaction().commit();↵ | 7 | session.getTransaction().commit();↵ | |
8 | session.close();↵ | 8 | session.close();↵ | |
9 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics( Container.class.getName() + ".contents" );↵ | 9 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics( Container.class.getName() + ".contents" );↵ | |
10 | long recreateCount = stats.getRecreateCount();↵ | 10 | long recreateCount = stats.getRecreateCount();↵ | |
11 | long updateCount = stats.getUpdateCount();↵ | 11 | long updateCount = stats.getUpdateCount();↵ | |
12 | container.setName( "another name" );↵ | |||
12 | session = openSession();↵ | 13 | session = openSession();↵ | |
13 | session.beginTransaction();↵ | 14 | session.beginTransaction();↵ | |
14 | container = ( Container ) session.get( Container.class, container.getId() );↵ | 15 | container = ( Container ) session.merge↵ | |
15 | assertEquals( 1, container.getContents().size() );↵ | 16 | ( container );↵ | |
16 | session.getTransaction().commit();↵ | 17 | session.getTransaction().commit();↵ | |
17 | session.close();↵ | 18 | session.close();↵ | |
18 | assertEquals( 1, container.getContents().size() );↵ | 19 | assertEquals( 1, container.getContents().size() );↵ | |
19 | assertEquals( recreateCount, stats.getRecreateCount() );↵ | 20 | assertEquals( recreateCount, stats.getRecreateCount() );↵ | |
20 | assertEquals( updateCount, stats.getUpdateCount() );↵ | 21 | assertEquals( updateCount, stats.getUpdateCount() );↵ | |
21 | session = openSession();↵ | 22 | session = openSession();↵ | |
22 | session.beginTransaction();↵ | 23 | session.beginTransaction();↵ | |
23 | container = ( Container ) session.get( Container.class, container.getId() );↵ | 24 | container = ( Container ) session.get( Container.class, container.getId() );↵ | |
24 | assertEquals( 1, container.getContents().size() );↵ | 25 | assertEquals( 1, container.getContents().size() );↵ | |
25 | session.delete( container );↵ | 26 | session.delete( container );↵ | |
26 | session.getTransaction().commit();↵ | 27 | session.getTransaction().commit();↵ | |
27 | session.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 declared in the same class |
Number of node comparisons | 185 |
Number of mapped statements | 27 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session session = openSession(); | 1 | Session session = openSession(); | |||||||||||||||||||||||||
2 | session.beginTransaction(); | 2 | session.beginTransaction(); | |||||||||||||||||||||||||
3 | Container container = new Container("p1"); | 3 | Container container = new Container("p1"); | |||||||||||||||||||||||||
4 | Container.Content c1 = new Container.Content("c1"); | 4 | Container.Content c1 = new Container.Content("c1"); | |||||||||||||||||||||||||
5 | container.getContents().add(c1); | 5 | container.getContents().add(c1); | |||||||||||||||||||||||||
6 | session.save(container); | 6 | session.save(container); | |||||||||||||||||||||||||
7 | session.getTransaction().commit(); | 7 | session.getTransaction().commit(); | |||||||||||||||||||||||||
8 | session.close(); | 8 | session.close(); | |||||||||||||||||||||||||
9 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics(Container.class.getName() + ".contents"); | 9 | CollectionStatistics stats = sfi().getStatistics().getCollectionStatistics(Container.class.getName() + ".contents"); | |||||||||||||||||||||||||
10 | long recreateCount = stats.getRecreateCount(); | 10 | long recreateCount = stats.getRecreateCount(); | |||||||||||||||||||||||||
11 | long updateCount = stats.getUpdateCount(); | 11 | long updateCount = stats.getUpdateCount(); | |||||||||||||||||||||||||
12 | session = openSession(); | 13 | session = openSession(); | |||||||||||||||||||||||||
13 | session.beginTransaction(); | 14 | session.beginTransaction(); | |||||||||||||||||||||||||
14 | container = (Container)session.get(Container.class, container.getId()); |
| 15 | container = (Container)session.merge(container); | ||||||||||||||||||||||||
15 | assertEquals(1, container.getContents().size()); |
| 12 | container.setName("another name"); | ||||||||||||||||||||||||
16 | session.getTransaction().commit(); | 16 | session.getTransaction().commit(); | |||||||||||||||||||||||||
17 | session.close(); | 17 | session.close(); | |||||||||||||||||||||||||
18 | assertEquals(1, container.getContents().size()); | 18 | assertEquals(1, container.getContents().size()); | |||||||||||||||||||||||||
19 | assertEquals(recreateCount, stats.getRecreateCount()); | 19 | assertEquals(recreateCount, stats.getRecreateCount()); | |||||||||||||||||||||||||
20 | assertEquals(updateCount, stats.getUpdateCount()); | 20 | assertEquals(updateCount, stats.getUpdateCount()); | |||||||||||||||||||||||||
21 | session = openSession(); | 21 | session = openSession(); | |||||||||||||||||||||||||
22 | session.beginTransaction(); | 22 | session.beginTransaction(); | |||||||||||||||||||||||||
23 | container = (Container)session.get(Container.class, container.getId()); | 23 | container = (Container)session.get(Container.class, container.getId()); | |||||||||||||||||||||||||
24 | assertEquals(1, container.getContents().size()); | 24 | assertEquals(1, container.getContents().size()); | |||||||||||||||||||||||||
25 | session.delete(container); | 25 | session.delete(container); | |||||||||||||||||||||||||
26 | session.getTransaction().commit(); | 26 | session.getTransaction().commit(); | |||||||||||||||||||||||||
27 | session.close(); | 27 | session.close(); |
Row | Violation |
---|---|
1 | Expression session.get(Container.class,container.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression session.merge(container) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression session.get(Container.class,container.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression session.merge(container) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression assertEquals(1,container.getContents().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression container.setName("another name") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression assertEquals(1,container.getContents().size()) is a void method call, and thus it cannot be parameterized |
8 | Expression container.setName("another name") is a void method call, and thus it cannot be parameterized |
9 | Expression assertEquals(1,container.getContents().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression container.setName("another name") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression assertEquals(1,container.getContents().size()) is a void method call, and thus it cannot be parameterized |
12 | Expression container.setName("another name") is a void method call, and thus it cannot be parameterized |