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(); }
try { Session s = openSession(); s.beginTransaction(); Parent p = new Parent( "parent" ); ParentInfo info = new ParentInfo( "xyz" ); p.setInfo( info ); info.setOwner( p ); s.persist( p ); 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 testOneToOnePropertyRefGeneratedIds() Method name: void testOneToOneGeneratedIds()
Number of AST nodes: 11 Number of AST nodes: 11
1
try {
1
try {
2
			Session s = openSession();
2
			Session s = openSession();
3
			s.beginTransaction();
3
			s.beginTransaction();
4
			Child c2 = new Child( "c2" );
4
			Parent p = new Parent( "parent" );
5
			ChildInfo info = new ChildInfo( "blah blah blah" );
5
			ParentInfo info = new ParentInfo( "xyz" );
6
			c2.setInfo( info );
6
			p.setInfo( info );
7
			info.setOwner( c2 );
7
			info.setOwner( p );
8
			s.persist( c2 );
8
			s.persist( p );
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 comparisons73
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)3.4
    Clone typeType 2
    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
    Child c2 = new Child("c2");
                                                            
                                                                                      
    5
    ParentInfo info = new ParentInfo("xyz");
    5
    ChildInfo info = new ChildInfo("blah blah blah");
                                                                                                        
    6
    c2.setInfo(info);
    6
    c2.setInfo(info);
    6
    p.setInfo(info);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.jpa.cascade.ChildInfoorg.hibernate.test.jpa.cascade.ParentInfoVARIABLE_TYPE_MISMATCH
    c2pVARIABLE_NAME_MISMATCH
    org.hibernate.test.jpa.cascade.Childorg.hibernate.test.jpa.cascade.ParentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.jpa.cascade.ChildInfo of variable info does not match with type org.hibernate.test.jpa.cascade.ParentInfo of variable info
    • Make classes org.hibernate.test.jpa.cascade.ChildInfo and org.hibernate.test.jpa.cascade.ParentInfo extend a common superclass
    Type org.hibernate.test.jpa.cascade.Child of variable c2 does not match with type org.hibernate.test.jpa.cascade.Parent of variable p
    • Make classes org.hibernate.test.jpa.cascade.Child and org.hibernate.test.jpa.cascade.Parent extend a common superclass
    6
    p.setInfo(info);
    7
    info.setOwner(c2);
    7
    info.setOwner(c2);
    7
    info.setOwner(p);
    Differences
    Expression1Expression2Difference
    c2pVARIABLE_NAME_MISMATCH
    org.hibernate.test.jpa.cascade.Childorg.hibernate.test.jpa.cascade.ParentVARIABLE_TYPE_MISMATCH
    org.hibernate.test.jpa.cascade.ChildInfoorg.hibernate.test.jpa.cascade.ParentInfoVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.jpa.cascade.Child of variable c2 does not match with type org.hibernate.test.jpa.cascade.Parent of variable p
    • Make classes org.hibernate.test.jpa.cascade.Child and org.hibernate.test.jpa.cascade.Parent extend a common superclass
    Type org.hibernate.test.jpa.cascade.ChildInfo of variable info does not match with type org.hibernate.test.jpa.cascade.ParentInfo of variable info
    • Make classes org.hibernate.test.jpa.cascade.ChildInfo and org.hibernate.test.jpa.cascade.ParentInfo extend a common superclass
    7
    info.setOwner(p);
    8
    s.persist(c2);
    8
    s.persist(c2);
    8
    s.persist(p);
    Differences
    Expression1Expression2Difference
    c2pVARIABLE_NAME_MISMATCH
    org.hibernate.test.jpa.cascade.Childorg.hibernate.test.jpa.cascade.ParentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.jpa.cascade.Child of variable c2 does not match with type org.hibernate.test.jpa.cascade.Parent of variable p
    • Make classes org.hibernate.test.jpa.cascade.Child and org.hibernate.test.jpa.cascade.Parent extend a common superclass
    8
    s.persist(p);
    9
    try
    9
    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) 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
    10
    s.getTransaction().commit();
    10
    s.getTransaction().commit();
    11
    fail("expecting TransientObjectException on flush");
    11
    fail("expecting TransientObjectException on flush");
    Precondition Violations (7)
    Row Violation
    1Type org.hibernate.test.jpa.cascade.ChildInfo of variable info does not match with type org.hibernate.test.jpa.cascade.ParentInfo of variable info
    2Type org.hibernate.test.jpa.cascade.Child of variable c2 does not match with type org.hibernate.test.jpa.cascade.Parent of variable p
    3Type org.hibernate.test.jpa.cascade.Child of variable c2 does not match with type org.hibernate.test.jpa.cascade.Parent of variable p
    4Type org.hibernate.test.jpa.cascade.ChildInfo of variable info does not match with type org.hibernate.test.jpa.cascade.ParentInfo of variable info
    5Type org.hibernate.test.jpa.cascade.Child of variable c2 does not match with type org.hibernate.test.jpa.cascade.Parent of variable p
    6Expression log.trace("handled expected exception : " + e) is a void method call, and thus it cannot be parameterized
    7Expression log.trace("handled expected exception",e) is a void method call, and thus it cannot be parameterized