Session s = openSession(); s.beginTransaction(); s.save( new Employee( "John", 'M', "john", new Date() ) ); s.save( new Employee( "Jane", 'F', "jane", new Date() ) ); s.save( new Customer( "Charlie", 'M', "charlie", "Acme" ) ); s.save( new Customer( "Wanda", 'F', "wanda", "ABC" ) ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.enableFilter( "sex" ).setParameter( "sexCode", new Character('M' ) ); int count = s.createQuery( "delete User" ).executeUpdate(); assertEquals( 2, count ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.createQuery( "delete Person" ).executeUpdate(); s.getTransaction().commit(); s.close();
Session s = openSession(); s.beginTransaction(); s.save( new Employee( "John", 'M', "john", new Date() ) ); s.save( new Employee( "Jane", 'F', "jane", new Date() ) ); s.save( new Customer( "Charlie", 'M', "charlie", "Acme" ) ); s.save( new Customer( "Wanda", 'F', "wanda", "ABC" ) ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.enableFilter( "sex" ).setParameter( "sexCode", new Character('M' ) ); int count = s.createQuery( "delete Person" ).executeUpdate(); assertEquals( 2, count ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.createQuery( "delete Person" ).executeUpdate(); s.getTransaction().commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/filter/hql/JoinedFilteredBulkManipulationTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/filter/hql/JoinedFilteredBulkManipulationTest.java
Method name: void testFilteredJoinedSubclassHqlDeleteNonLeaf() Method name: void testFilteredJoinedSubclassHqlDeleteRoot()
Number of AST nodes: 20 Number of AST nodes: 20
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		s.beginTransaction();
3
		s.save( new Employee( "John", 'M', "john", new Date() ) );
3
		s.save( new Employee( "John", 'M', "john", new Date() ) );
4
		s.save( new Employee( "Jane", 'F', "jane", new Date() ) );
4
		s.save( new Employee( "Jane", 'F', "jane", new Date() ) );
5
		s.save( new Customer( "Charlie", 'M', "charlie", "Acme" ) );
5
		s.save( new Customer( "Charlie", 'M', "charlie", "Acme" ) );
6
		s.save( new Customer( "Wanda", 'F', "wanda", "ABC" ) );
6
		s.save( new Customer( "Wanda", 'F', "wanda", "ABC" ) );
7
		s.getTransaction().commit();
7
		s.getTransaction().commit();
8
		s.close();
8
		s.close();
9
		s = openSession();
9
		s = openSession();
10
		s.beginTransaction();
10
		s.beginTransaction();
11
		s.enableFilter( "sex" ).setParameter( "sexCode", new Character('M' ) );
11
		s.enableFilter( "sex" ).setParameter( "sexCode", new Character('M' ) );
12
		int count = s.createQuery( "delete User" ).executeUpdate();
12
		int count = s.createQuery( "delete Person" ).executeUpdate();
13
		assertEquals( 2, count );
13
		assertEquals( 2, count );
14
		s.getTransaction().commit();
14
		s.getTransaction().commit();
15
		s.close();
15
		s.close();
16
		s = openSession();
16
		s = openSession();
17
		s.beginTransaction();
17
		s.beginTransaction();
18
		s.createQuery( "delete Person" ).executeUpdate();
18
		s.createQuery( "delete Person" ).executeUpdate();
19
		s.getTransaction().commit();
19
		s.getTransaction().commit();
20
		s.close();
20
		s.close();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are declared in the same class
Number of node comparisons112
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements20
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
    2
    s.beginTransaction();
    2
    s.beginTransaction();
    3
    s.save(new Employee("John", 'M', "john", new Date()));
    3
    s.save(new Employee("John", 'M', "john", new Date()));
    4
    s.save(new Employee("Jane", 'F', "jane", new Date()));
    4
    s.save(new Employee("Jane", 'F', "jane", new Date()));
    5
    s.save(new Customer("Charlie", 'M', "charlie", "Acme"));
    5
    s.save(new Customer("Charlie", 'M', "charlie", "Acme"));
    6
    s.save(new Customer("Wanda", 'F', "wanda", "ABC"));
    6
    s.save(new Customer("Wanda", 'F', "wanda", "ABC"));
    7
    s.getTransaction().commit();
    7
    s.getTransaction().commit();
    8
    s.close();
    8
    s.close();
    9
    s = openSession();
    9
    s = openSession();
    10
    s.beginTransaction();
    10
    s.beginTransaction();
    11
    s.enableFilter("sex").setParameter("sexCode", new Character('M'));
    11
    s.enableFilter("sex").setParameter("sexCode", new Character('M'));
    12
    int count = s.createQuery("delete User").executeUpdate();
    12
    int count = s.createQuery("delete User").executeUpdate();
    12
    int count = s.createQuery("delete Person").executeUpdate();
    Differences
    Expression1Expression2Difference
    "delete User""delete Person"LITERAL_VALUE_MISMATCH
    12
    int count = s.createQuery("delete Person").executeUpdate();
    13
    assertEquals(2, count);
    13
    assertEquals(2, count);
    14
    s.getTransaction().commit();
    14
    s.getTransaction().commit();
    15
    s.close();
    15
    s.close();
    16
    s = openSession();
    16
    s = openSession();
    17
    s.beginTransaction();
    17
    s.beginTransaction();
    18
    s.createQuery("delete Person").executeUpdate();
    18
    s.createQuery("delete Person").executeUpdate();
    19
    s.getTransaction().commit();
    19
    s.getTransaction().commit();
    20
    s.close();
    20
    s.close();
    Precondition Violations (0)
    Row Violation