Session s = openSession(); s.beginTransaction(); Customer cust = new Customer( "Acme, Inc." ); Order order = new Order( new Order.Id( cust, 1 ) ); cust.getOrders().add( order ); s.save( cust ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); try { cust = ( Customer ) s.get( Customer.class, cust.getId() ); } catch( OverflowCondition overflow ) { fail( "get()/load() caused overflow condition" ); } s.delete( cust ); s.getTransaction().commit(); s.close();
Session s = openSession(); Vetoer v = new Vetoer(); v.setStrings( new String[] { "foo", "bar", "baz" } ); s.save(v); Serializable id = s.save(v); v.getStrings()[1] = "osama"; s.flush(); s.connection().commit(); s.close(); s = openSession(); v = (Vetoer) s.load(Vetoer.class, id); assertTrue( "serializable type", v.getStrings()[1].equals("osama") ); s.delete(v); s.delete(v); s.flush(); s.connection().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/keymanytoone/bidir/component/EagerKeyManyToOneTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Method name: void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected() Method name: void testSerializableType()
Number of AST nodes: 15 Number of AST nodes: 17
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		Vetoer v = new Vetoer();
3
		Customer cust = new Customer( "Acme, Inc." );
3
		v.setStrings( new String[] { "foo", "bar", "baz" } );
4
		Order order = new Order( new Order.Id( cust, 1 ) );
4
		s.save(v); Serializable id = s.save(v);
5
		cust.getOrders().add( order );
5
		
6
		s.save( cust 
6
v.getStrings()[1] = "osama";
7
);
7
		s.flush();
8
		s.getTransaction().commit();
8
		s.connection().commit();
9
		s.close();
9
		s.close();
10

11
		s = openSession();
10
		s = openSession();
12
		s.beginTransaction();
11
		
13
		try {
14
			cust = ( Customer ) s.get( Customer.class, cust.getId() );
12
v = (Vetoer) s.load(Vetoer.class, id);
15
		}
13
		
16
		catch( OverflowCondition overflow ) {
17
			fail( "get()/load() caused overflow condition" );
18
		}
19
		s.delete( cust 
14
assertTrue( "serializable type", v.getStrings()[1].equals("osama") );
15
		s.delete(v); s.delete(v);
20
);
16
		s.flush();
21
		s.getTransaction().commit();
17
		s.connection().commit();
22
		s.close();
18
		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.0
Clones locationClones are in different classes having the same super class
Number of node comparisons169
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment9
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    1
    Session s = openSession();
                                                      
    2
    Vetoer v = new Vetoer();
    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
    v.setStrings(new String[] {"foo", "bar", "baz"});
    Preondition Violations
    Unmatched statement v.setStrings(new String[]{"foo","bar","baz"}); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    v.setStrings(new String[] {"foo", "bar", "baz"});
    3
    Customer cust = new Customer("Acme, Inc.");
    3
    Customer cust = new Customer("Acme, Inc.");
    Preondition Violations
    Unmatched statement Customer cust=new Customer("Acme, Inc."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                            
    4
    Order order = new Order(new Order.Id(cust, 1));
    4
    Order order = new Order(new Order.Id(cust, 1));
    Preondition Violations
    Unmatched statement Order order=new Order(new Order.Id(cust,1)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                  
    5
    cust.getOrders().add(order);
                                                                  
    6
    s.save(cust);
    6
    s.save(cust);
    4
    s.save(v);
    Differences
    Expression1Expression2Difference
    custvVARIABLE_NAME_MISMATCH
    org.hibernate.test.keymanytoone.bidir.component.Customerorg.hibernate.test.legacy.VetoerVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    • Make classes org.hibernate.test.keymanytoone.bidir.component.Customer and org.hibernate.test.legacy.Vetoer extend a common superclass
    4
    s.save(v);
                                                              
    5
    Serializable id = s.save(v);
    Preondition Violations
    Unmatched statement Serializable id=s.save(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    Serializable id = s.save(v);
                                                              
    6
    v.getStrings()[1] = "osama";
                              
    7
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    s.flush();
    7
    s.getTransaction().commit();
    7
    s.getTransaction().commit();
    8
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    8
    s.connection().commit();
    8
    s.close();
    8
    s.close();
    9
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    9
    s.close();
    9
    s = openSession();
    9
    s = openSession();
    10
    s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    10
    s = openSession();
    10
    s.beginTransaction();
    10
    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
                                                      
                                                                                
    11
    v = (Vetoer)s.load(Vetoer.class, id);
    Preondition Violations
    Unmatched statement v=(Vetoer)s.load(Vetoer.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    v = (Vetoer)s.load(Vetoer.class, id);
                                                                                                                                                
    12
    assertTrue("serializable type", v.getStrings()[1].equals("osama"));
    13
    s.delete(cust);
    13
    s.delete(cust);
    13
    s.delete(v);
    Differences
    Expression1Expression2Difference
    custvVARIABLE_NAME_MISMATCH
    org.hibernate.test.keymanytoone.bidir.component.Customerorg.hibernate.test.legacy.VetoerVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    • Make classes org.hibernate.test.keymanytoone.bidir.component.Customer and org.hibernate.test.legacy.Vetoer extend a common superclass
    13
    s.delete(v);
                                    
    14
    s.delete(v);
    Preondition Violations
    Unmatched statement s.delete(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    s.delete(v);
                                
    15
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    s.flush();
    14
    s.getTransaction().commit();
    14
    s.getTransaction().commit();
    16
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    16
    s.connection().commit();
    15
    s.close();
    15
    s.close();
    17
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    17
    s.close();
    Precondition Violations (19)
    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 v.setStrings(new String[]{"foo","bar","baz"}); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement Customer cust=new Customer("Acme, Inc."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement Order order=new Order(new Order.Id(cust,1)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    6Unmatched statement Serializable id=s.save(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression s.connection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    11Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement v=(Vetoer)s.load(Vetoer.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    14Unmatched statement s.delete(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression s.connection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    19Clone fragment #1 returns variable s with type org.hibernate.Session , while Clone fragment #2 returns variable s with type org.hibernate.classic.Session