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 statements11
    Number of unmapped statements in the first code fragment10
    Number of unmapped statements in the second code fragment12
    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");
                                                                                                                                                                
    4
    SimpleAssociatedEntity e1 = new SimpleAssociatedEntity("thing one", owner);
                                                                                                                                                          
    5
    SimpleAssociatedEntity e2 = new SimpleAssociatedEntity("thing two");
                                                                                                                                              
    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();
    8
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    tx.commit();
    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");
                                                                    
    5
    Node child = new Node("child");
                                                    
    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);
    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");
    10
    assertInsertCount(2);
    Differences
    Expression1Expression2Difference
    checkCountsassertInsertCountMETHOD_INVOCATION_NAME_MISMATCH
    checkCounts("from SimpleAssociatedEntity e order by e.owner",2,"implicit-join in order-by clause")assertInsertCount(2)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 assertInsertCount(2) 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 assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    10
    assertInsertCount(2);
                                                                                      
    12
    root.setDescription("The root node");
                                                                                          
    13
    child.setDescription("The child node");
                                                                                                
    14
    Node secondChild = new Node("second child");
                                                                  
    15
    root.addChild(secondChild);
    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");
    21
    assertInsertCount(1);
    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(1)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(1) 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(1) is a void method call, and thus it cannot be parameterized
    21
    assertInsertCount(1);
    15
    s = openSession();
    16
    s = openSession();
    16
    s.beginTransaction();
                                                      
                                                            
    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);
                                                      
    22
    assertUpdateCount(2);
    17
    s.delete(e1);
    17
    s.delete(e1);
    23
    cleanup();
    Differences
    Expression1Expression2Difference
    deletecleanupMETHOD_INVOCATION_NAME_MISMATCH
    s.delete(e1)cleanup()ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.delete(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(e1) 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 s.delete(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(e1) 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();
    18
    s.delete(e2);
                                      
    19
    s.delete(owner);
                                            
    20
    s.getTransaction().commit();
    20
    s.getTransaction().commit();
    19
    tx.commit();
    Differences
    Expression1Expression2Difference
    s.getTransaction()txTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19
    tx.commit();
    21
    s.close();
    20
    s.close();
    Precondition Violations (31)
    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 s.save(e1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement s.save(e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement s.save(owner); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    7Expression clearCounts() is a void method call, and thus it cannot be parameterized
    8Expression checkCounts("select e.owner from SimpleAssociatedEntity e",1,"implicit-join in select clause") is a void method call, and thus it cannot be parameterized
    9Expression clearCounts() is a void method call, and thus it cannot be parameterized
    10Expression 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
    11Expression clearCounts() is a void method call, and thus it cannot be parameterized
    12Expression 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
    13Expression clearCounts() is a void method call, and thus it cannot be parameterized
    14Unmatched 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
    15Unmatched statement s.persist(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Expression 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
    17Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    18Expression 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
    19Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    20Expression 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
    21Expression assertInsertCount(1) is a void method call, and thus it cannot be parameterized
    22Expression 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
    23Expression assertInsertCount(1) is a void method call, and thus it cannot be parameterized
    24Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Expression s.delete(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression s.delete(e1) is a void method call, and thus it cannot be parameterized
    27Expression cleanup() is a void method call, and thus it cannot be parameterized
    28Expression s.delete(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression s.delete(e1) is a void method call, and thus it cannot be parameterized
    30Expression cleanup() is a void method call, and thus it cannot be parameterized
    31Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted