Session s = openSession(); s.beginTransaction(); ExceptionCheckingEntity e = new ExceptionCheckingEntity(); e.setId( new Long( 1 ) ); e.setName( "dummy" ); s.delete( e ); try { s.flush(); fail( "expection flush failure!" ); } catch( JDBCException ex ) { // these should specifically be JDBCExceptions... } s.clear(); s.getTransaction().commit(); s.close();
Session s = openSession(); s.beginTransaction(); ParamCheckingEntity e = new ParamCheckingEntity(); e.setId( new Long( 1 ) ); e.setName( "dummy" ); s.delete( e ); try { s.flush(); fail( "expection flush failure!" ); } catch( HibernateException ex ) { // these should specifically be HibernateExceptions... } s.clear(); 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/sql/check/ResultCheckStyleTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/sql/check/ResultCheckStyleTest.java
Method name: void testDeleteWithExceptionChecking() Method name: void testDeleteWithParamChecking()
Number of AST nodes: 12 Number of AST nodes: 12
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		s.beginTransaction();
3
		ExceptionCheckingEntity e = new ExceptionCheckingEntity();
3
		ParamCheckingEntity e = new ParamCheckingEntity();
4
		e.setId( new Long( 1 ) );
4
		e.setId( new Long( 1 ) );
5
		e.setName( "dummy" );
5
		e.setName( "dummy" );
6
		s.delete( e );
6
		s.delete( e );
7
		try {
7
		try {
8
			s.flush();
8
			s.flush();
9
			fail( "expection flush failure!" );
9
			fail( "expection flush failure!" );
10
		}
10
		}
11
		catch( JDBCException ex ) {
11
		catch( HibernateException ex ) {
12
			// these should specifically be JDBCExceptions...
12
			// these should specifically be HibernateExceptions...
13
		}
13
		}
14
		s.clear();
14
		s.clear();
15
		s.getTransaction().commit();
15
		s.getTransaction().commit();
16
		s.close();
16
		s.close();
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.1
Clones locationClones are declared in the same class
Number of node comparisons66
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)3.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
    2
    s.beginTransaction();
    2
    s.beginTransaction();
                                                                                                          
    3
    ParamCheckingEntity e = new ParamCheckingEntity();
    3
    ExceptionCheckingEntity e = new ExceptionCheckingEntity();
                                                                                                                          
    4
    e.setId(new Long(1));
    4
    e.setId(new Long(1));
    4
    e.setId(new Long(1));
    Differences
    Expression1Expression2Difference
    org.hibernate.test.sql.check.ExceptionCheckingEntityorg.hibernate.test.sql.check.ParamCheckingEntityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.sql.check.ExceptionCheckingEntity of variable e does not match with type org.hibernate.test.sql.check.ParamCheckingEntity of variable e
    • Make classes org.hibernate.test.sql.check.ExceptionCheckingEntity and org.hibernate.test.sql.check.ParamCheckingEntity extend a common superclass
    4
    e.setId(new Long(1));
    5
    e.setName("dummy");
    5
    e.setName("dummy");
    5
    e.setName("dummy");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.sql.check.ExceptionCheckingEntityorg.hibernate.test.sql.check.ParamCheckingEntityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.sql.check.ExceptionCheckingEntity of variable e does not match with type org.hibernate.test.sql.check.ParamCheckingEntity of variable e
    • Make classes org.hibernate.test.sql.check.ExceptionCheckingEntity and org.hibernate.test.sql.check.ParamCheckingEntity extend a common superclass
    5
    e.setName("dummy");
    6
    s.delete(e);
    6
    s.delete(e);
    6
    s.delete(e);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.sql.check.ExceptionCheckingEntityorg.hibernate.test.sql.check.ParamCheckingEntityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.sql.check.ExceptionCheckingEntity of variable e does not match with type org.hibernate.test.sql.check.ParamCheckingEntity of variable e
    • Make classes org.hibernate.test.sql.check.ExceptionCheckingEntity and org.hibernate.test.sql.check.ParamCheckingEntity extend a common superclass
    6
    s.delete(e);
    7
    try
    7
    try
    7
    try
    Differences
    Expression1Expression2Difference
    org.hibernate.JDBCExceptionorg.hibernate.HibernateExceptionSUBCLASS_TYPE_MISMATCH
    org.hibernate.JDBCExceptionorg.hibernate.HibernateExceptionSUBCLASS_TYPE_MISMATCH
    7
    try
    8
    s.flush();
    8
    s.flush();
    9
    fail("expection flush failure!");
    9
    fail("expection flush failure!");
    10
    s.clear();
    10
    s.clear();
    11
    s.getTransaction().commit();
    11
    s.getTransaction().commit();
    12
    s.close();
    12
    s.close();
    Precondition Violations (3)
    Row Violation
    1Type org.hibernate.test.sql.check.ExceptionCheckingEntity of variable e does not match with type org.hibernate.test.sql.check.ParamCheckingEntity of variable e
    2Type org.hibernate.test.sql.check.ExceptionCheckingEntity of variable e does not match with type org.hibernate.test.sql.check.ParamCheckingEntity of variable e
    3Type org.hibernate.test.sql.check.ExceptionCheckingEntity of variable e does not match with type org.hibernate.test.sql.check.ParamCheckingEntity of variable e