try { Session s = openSession(); s.beginTransaction(); Parent p = new Parent( "parent" ); Child c = new Child( "child" ); c.setParent( p ); s.save( c ); try { s.getTransaction().commit(); fail( "expecting TransientObjectException on flush" ); } catch( TransientObjectException e ) { // expected result log.trace( "handled expected exception", e ); s.getTransaction().rollback(); } finally { s.close(); } } finally { cleanupData(); }
try { Session s = openSession(); s.beginTransaction(); Child c2 = new Child( "c2" ); ChildInfo info = new ChildInfo( "blah blah blah" ); c2.setInfo( info ); info.setOwner( c2 ); s.persist( c2 ); try { s.getTransaction().commit(); fail( "expecting TransientObjectException on flush" ); } catch( TransientObjectException e ) { // expected result log.trace( "handled expected exception : " + e ); s.getTransaction().rollback(); } finally { s.close(); } } finally { cleanupData(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/jpa/cascade/CascadeTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/jpa/cascade/CascadeTest.java
Method name: void testManyToOneGeneratedIdsOnSave() Method name: void testOneToOnePropertyRefGeneratedIds()
Number of AST nodes: 10 Number of AST nodes: 11
1
try {
1
try {
2
			Session s = openSession();
2
			Session s = openSession();
3
			s.beginTransaction();
3
			s.beginTransaction();
4
			Parent p = new Parent( "parent" );
4
			Child c2 = new Child( "c2" );
5
			Child c = new Child( "child" );
5
			ChildInfo info = new ChildInfo( "blah blah blah" );
6
			c.setParent( p
6
			c2.setInfo( info );
7
 );
7
			info.setOwner( c2 );
8
			s.save( c );
8
			s.persist( c2 );
9
			try {
9
			try {
10
				s.getTransaction().commit();
10
				s.getTransaction().commit();
11
				fail( "expecting TransientObjectException on flush" );
11
				fail( "expecting TransientObjectException on flush" );
12
			}
12
			}
13
			catch( TransientObjectException e ) {
13
			catch( TransientObjectException e ) {
14
				// expected result
14
				// expected result
15
				log.trace( "handled expected exception", e );
15
				log.trace( "handled expected exception : " + e );
16
				s.getTransaction().rollback();
16
				s.getTransaction().rollback();
17
			}
17
			}
18
			finally {
18
			finally {
19
				s.close();
19
				s.close();
20
			}
20
			}
21
		}
21
		}
22
		finally {
22
		finally {
23
			cleanupData();
23
			cleanupData();
24
		}
24
		}
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.4
Clones locationClones are declared in the same class
Number of node comparisons65
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)3.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    try
    1
    try
    2
    Session s = openSession();
    2
    Session s = openSession();
    3
    s.beginTransaction();
    3
    s.beginTransaction();
    4
    Parent p = new Parent("parent");
    4
    Parent p = new Parent("parent");
    Preondition Violations
    Unmatched statement Parent p=new Parent("parent"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                      
    5
    Child c = new Child("child");
    5
    Child c = new Child("child");
    4
    Child c2 = new Child("c2");
    Differences
    Expression1Expression2Difference
    cc2VARIABLE_NAME_MISMATCH
    "child""c2"LITERAL_VALUE_MISMATCH
    4
    Child c2 = new Child("c2");
                                                                                                        
    5
    ChildInfo info = new ChildInfo("blah blah blah");
    Preondition Violations
    Unmatched statement ChildInfo info=new ChildInfo("blah blah blah"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    ChildInfo info = new ChildInfo("blah blah blah");
                                            
    6
    c2.setInfo(info);
    Preondition Violations
    Unmatched statement c2.setInfo(info); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    c2.setInfo(info);
    6
    c.setParent(p);
    6
    c.setParent(p);
    Preondition Violations
    Unmatched statement c.setParent(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                        
                                              
    7
    info.setOwner(c2);
    Preondition Violations
    Unmatched statement info.setOwner(c2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    info.setOwner(c2);
    7
    s.save(c);
    7
    s.save(c);
    Preondition Violations
    Unmatched statement s.save(c); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement s.save(c); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                              
                                      
    8
    s.persist(c2);
    Preondition Violations
    Unmatched statement s.persist(c2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement s.persist(c2); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    8
    s.persist(c2);
    8
    try
    8
    try
    9
    try
    Differences
    Expression1Expression2Difference
    log.trace("handled expected exception",e)log.trace("handled expected exception : " + e)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression log.trace("handled expected exception",e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression log.trace("handled expected exception : " + e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression log.trace("handled expected exception",e) is a void method call, and thus it cannot be parameterized
    Expression log.trace("handled expected exception : " + e) is a void method call, and thus it cannot be parameterized
    9
    try
    9
    s.getTransaction().commit();
    10
    s.getTransaction().commit();
    10
    fail("expecting TransientObjectException on flush");
    11
    fail("expecting TransientObjectException on flush");
    Precondition Violations (14)
    Row Violation
    1Unmatched statement Parent p=new Parent("parent"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement ChildInfo info=new ChildInfo("blah blah blah"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement c2.setInfo(info); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement c.setParent(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement info.setOwner(c2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement s.save(c); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s.save(c); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    8Unmatched statement s.persist(c2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement s.persist(c2); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    10Expression log.trace("handled expected exception",e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression log.trace("handled expected exception : " + e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression log.trace("handled expected exception",e) is a void method call, and thus it cannot be parameterized
    13Expression log.trace("handled expected exception : " + e) is a void method call, and thus it cannot be parameterized
    14Clone fragment #1 returns variables c, s , while Clone fragment #2 returns variables c2, s