Session s = openSession(); s.beginTransaction(); SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation( "owner" ); SimpleAssociatedEntity e1 = new SimpleAssociatedEntity( "thing one", owner ); SimpleAssociatedEntity e2 = new SimpleAssociatedEntity( "thing two" ); s.save( e1 ); s.save( e2 ); s.save( owner ); s.getTransaction().commit(); s.close(); checkCounts( "select e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause" ); checkCounts( "select e.id, e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause" ); // resolved to a "id short cut" when part of the order by clause -> no inner join = no weeding out... checkCounts( "from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause" ); // resolved to a "id short cut" when part of the group by clause -> no inner join = no weeding out... checkCounts( "select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses" ); s = openSession(); s.beginTransaction(); s.delete( e1 ); s.delete( e2 ); s.delete( owner ); s.getTransaction().commit(); s.close();
clearCounts(); Session s = openSession(); Transaction tx = s.beginTransaction(); Node root = new Node("root"); Node child = new Node("child"); root.addChild(child); s.persist(root); tx.commit(); s.close(); assertInsertCount(2); clearCounts(); root.setDescription("The root node"); child.setDescription("The child node"); Node secondChild = new Node("second child"); root.addChild(secondChild); s = openSession(); tx = s.beginTransaction(); s.merge(root); tx.commit(); s.close(); assertInsertCount(1); assertUpdateCount(2); cleanup();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java
Method name: void testImplicitJoinsInDifferentClauses() Method name: void testMergeTree()
Number of AST nodes: 21 Number of AST nodes: 23
1
clearCounts();
1
Session s = openSession();
2
		Session s = openSession();
2
		s.beginTransaction();
3
		Transaction
3
		SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation( "owner" );
4
		SimpleAssociatedEntity e1 = new SimpleAssociatedEntity( "thing one", owner );
5
		SimpleAssociatedEntity e2 = new SimpleAssociatedEntity( "thing two" );
6
		s.save( e1 );
7
		s.save( e2 );
8
		s.save( owner );
9
		s.getTransaction().commit();
10
		s.close();
11
		checkCounts( "select e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause" 
4
 tx = s.beginTransaction();
5
		Node root = new Node("root");
6
		Node child = new Node("child");
7
		root.addChild(child);
8
		s.persist(root);
9
		tx.commit();
10
		s.close();
12
);
11
		assertInsertCount(2);
13
		checkCounts( "select e.id, e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause" );
12
		clearCounts(
14
		// resolved to a "id short cut" when part of the order by clause -> no inner join = no weeding out...
15
		checkCounts( "from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause" 
13
);
14
		root.setDescription("The root node");
16
);
15
		child.setDescription("The child node");
17
		// resolved to a "id short cut" when part of the group by clause -> no inner join = no weeding out...
16
		
18
		checkCounts( "select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses" 
17
Node secondChild = new Node("second child");
19
);
18
		root.addChild(secondChild);
20
	 	s = openSession();
19
		s = openSession();
21
		s.beginTransaction();
20
		tx = s.beginTransaction();
22
		s.delete( e1 );
21
		s.
23
		s.delete( e2 );
24
		s.delete( owner 
22
merge(root);
23
		tx.commit();
25
);
24
		s.close();
26
		s.getTransaction().commi
25
		assertInsertCount(1);
27
t();
26
		assertUpdateCount(2);
28
		s.close();
27
		cleanup();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in different classes having the same super class
Number of node comparisons403
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment13
    Number of unmapped statements in the second code fragment15
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    2
    Session s = openSession();
    2
    s.beginTransaction();
    2
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    3
    SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation("owner");
    3
    SimpleEntityWithAssociation owner = new SimpleEntityWithAssociation("owner");
    Preondition Violations
    Unmatched statement SimpleEntityWithAssociation owner=new SimpleEntityWithAssociation("owner"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                
    4
    SimpleAssociatedEntity e1 = new SimpleAssociatedEntity("thing one", owner);
    4
    SimpleAssociatedEntity e1 = new SimpleAssociatedEntity("thing one", owner);
    Preondition Violations
    Unmatched statement SimpleAssociatedEntity e1=new SimpleAssociatedEntity("thing one",owner); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                          
    5
    SimpleAssociatedEntity e2 = new SimpleAssociatedEntity("thing two");
    5
    SimpleAssociatedEntity e2 = new SimpleAssociatedEntity("thing two");
    Preondition Violations
    Unmatched statement SimpleAssociatedEntity e2=new SimpleAssociatedEntity("thing two"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                              
    6
    s.save(e1);
    6
    s.save(e1);
    Preondition Violations
    Unmatched statement s.save(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    7
    s.save(e2);
    7
    s.save(e2);
    Preondition Violations
    Unmatched statement s.save(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    8
    s.save(owner);
    8
    s.save(owner);
    Preondition Violations
    Unmatched statement s.save(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                      
    9
    s.getTransaction().commit();
    9
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                  
    10
    s.close();
    9
    s.close();
    11
    checkCounts("select e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause");
    11
    checkCounts("select e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause");
    11
    clearCounts();
    Differences
    Expression1Expression2Difference
    checkCountsclearCountsMETHOD_INVOCATION_NAME_MISMATCH
    checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause")clearCounts()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    11
    clearCounts();
    12
    checkCounts("select e.id, e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause");
    12
    checkCounts("select e.id, e.owner from SimpleAssociatedEntity e", 1, "implicit-join in select clause");
    1
    clearCounts();
    Differences
    Expression1Expression2Difference
    checkCountsclearCountsMETHOD_INVOCATION_NAME_MISMATCH
    checkCounts("select e.id, e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause")clearCounts()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression checkCounts("select e.id, e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    Expression checkCounts("select e.id, e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    1
    clearCounts();
                                                                                  
    3
    Transaction tx = s.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    Transaction tx = s.beginTransaction();
                                                                
    4
    Node root = new Node("root");
    Preondition Violations
    Unmatched statement Node root=new Node("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    Node root = new Node("root");
                                                                    
    5
    Node child = new Node("child");
    Preondition Violations
    Unmatched statement Node child=new Node("child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    Node child = new Node("child");
                                                    
    6
    root.addChild(child);
    Preondition Violations
    Unmatched statement root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6
    root.addChild(child);
                                          
    7
    s.persist(root);
    Preondition Violations
    Unmatched statement s.persist(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    s.persist(root);
                                  
    8
    tx.commit();
    Preondition Violations
    Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8
    tx.commit();
                                                                                      
    12
    root.setDescription("The root node");
    Preondition Violations
    Unmatched statement root.setDescription("The root node"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12
    root.setDescription("The root node");
                                                                                          
    13
    child.setDescription("The child node");
    Preondition Violations
    Unmatched statement child.setDescription("The child node"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13
    child.setDescription("The child node");
                                                                                                
    14
    Node secondChild = new Node("second child");
    Preondition Violations
    Unmatched statement Node secondChild=new Node("second child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14
    Node secondChild = new Node("second child");
                                                                  
    15
    root.addChild(secondChild);
    Preondition Violations
    Unmatched statement root.addChild(secondChild); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    15
    root.addChild(secondChild);
                                                            
    17
    tx = s.beginTransaction();
    Preondition Violations
    Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    tx = s.beginTransaction();
                                        
    18
    s.merge(root);
    Preondition Violations
    Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18
    s.merge(root);
                                    
    19
    tx.commit();
    Preondition Violations
    Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    19
    tx.commit();
                                                      
    21
    assertInsertCount(1);
                                                      
    22
    assertUpdateCount(2);
    13
    checkCounts("from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause");
    13
    checkCounts("from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause");
    23
    cleanup();
    Differences
    Expression1Expression2Difference
    checkCountscleanupMETHOD_INVOCATION_NAME_MISMATCH
    checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause")cleanup()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause") is a void method call, and thus it cannot be parameterized
    Expression cleanup() is a void method call, and thus it cannot be parameterized
    Expression checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause") is a void method call, and thus it cannot be parameterized
    Expression cleanup() is a void method call, and thus it cannot be parameterized
    23
    cleanup();
    14
    checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses");
    14
    checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses");
    10
    assertInsertCount(2);
    Differences
    Expression1Expression2Difference
    checkCountsassertInsertCountMETHOD_INVOCATION_NAME_MISMATCH
    checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",2,"implicit-join in select and group-by clauses")assertInsertCount(2)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",2,"implicit-join in select and group-by clauses") is a void method call, and thus it cannot be parameterized
    Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    Expression checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",2,"implicit-join in select and group-by clauses") is a void method call, and thus it cannot be parameterized
    Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    10
    assertInsertCount(2);
    15
    s = openSession();
    16
    s = openSession();
    16
    s.beginTransaction();
    16
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                      
    17
    s.delete(e1);
    17
    s.delete(e1);
    Preondition Violations
    Unmatched statement s.delete(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                      
    18
    s.delete(e2);
    18
    s.delete(e2);
    Preondition Violations
    Unmatched statement s.delete(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                      
    19
    s.delete(owner);
    19
    s.delete(owner);
    Preondition Violations
    Unmatched statement s.delete(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
    20
    s.getTransaction().commit();
    20
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
    21
    s.close();
    20
    s.close();
    Precondition Violations (43)
    Row Violation
    1Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement SimpleEntityWithAssociation owner=new SimpleEntityWithAssociation("owner"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement SimpleAssociatedEntity e1=new SimpleAssociatedEntity("thing one",owner); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement SimpleAssociatedEntity e2=new SimpleAssociatedEntity("thing two"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement s.save(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement s.save(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s.save(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    10Expression clearCounts() is a void method call, and thus it cannot be parameterized
    11Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    12Expression clearCounts() is a void method call, and thus it cannot be parameterized
    13Expression checkCounts("select e.id, e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    14Expression clearCounts() is a void method call, and thus it cannot be parameterized
    15Expression checkCounts("select e.id, e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    16Expression clearCounts() is a void method call, and thus it cannot be parameterized
    17Unmatched statement Transaction tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement Node root=new Node("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    19Unmatched statement Node child=new Node("child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    20Unmatched statement root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    21Unmatched statement s.persist(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    23Unmatched statement root.setDescription("The root node"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    24Unmatched statement child.setDescription("The child node"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    25Unmatched statement Node secondChild=new Node("second child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    26Unmatched statement root.addChild(secondChild); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    27Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    28Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    30Expression checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause") is a void method call, and thus it cannot be parameterized
    31Expression cleanup() is a void method call, and thus it cannot be parameterized
    32Expression checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause") is a void method call, and thus it cannot be parameterized
    33Expression cleanup() is a void method call, and thus it cannot be parameterized
    34Expression checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",2,"implicit-join in select and group-by clauses") is a void method call, and thus it cannot be parameterized
    35Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    36Expression checkCounts("select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",2,"implicit-join in select and group-by clauses") is a void method call, and thus it cannot be parameterized
    37Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    38Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    39Unmatched statement s.delete(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    40Unmatched statement s.delete(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    41Unmatched statement s.delete(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    42Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    43Clone fragment #1 returns variables s , while Clone fragment #2 returns variables