if ( !dialect.supportsUniqueConstraintInCreateAlterTable() ) { Iterator subIter = table.getUniqueKeyIterator(); while ( subIter.hasNext() ) { UniqueKey uk = (UniqueKey) subIter.next(); String constraintString = uk.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema ); if (constraintString != null) script.add( constraintString ); } }
EntityEntry e = persistenceContext.removeEntry( object ); if ( e != null ) { EntityKey key = new EntityKey( e.getId(), e.getPersister(), source.getEntityMode() ); persistenceContext.removeEntity( key ); doEvict( object, key, e.getPersister(), source ); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/Configuration.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/event/def/DefaultEvictEventListener.java
Method name: String[] generateSchemaCreationScript(Dialect) Method name: void onEvict(EvictEvent)
Number of AST nodes: 7 Number of AST nodes: 5
1
if ( !dialect.supportsUniqueConstraintInCreateAlterTable() ) {
2
					Iterator subIter = table.getUniqueKeyIterator();
1
EntityEntry e = persistenceContext.removeEntry( object );
3
					while ( subIter.hasNext() ) {
2
			if ( e != null ) {
4
						UniqueKey uk = (UniqueKey) subIter.next();
3
				EntityKey 
5
						String constraintString = uk.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema );
6
						if (constraintString != null) script.add( constraintString );
7
					}
8
	
4
key = new EntityKey( e.getId(), e.getPersister(), source.getEntityMode()  );
5
				persistenceContext.removeEntity( key );
6
				doEvict( object, key, e.getPersister(), source );
9
			}
7
			}
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 in different classes
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)0.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                      
    18
    EntityEntry e = persistenceContext.removeEntry(object);
    20
    UniqueKey uk = (UniqueKey)subIter.next();
                                                                                          
    21
    String constraintString = uk.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema);
    21
    String constraintString = uk.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema);
    Preondition Violations
    Unmatched statement String constraintString=uk.sqlCreateString(dialect,mapping,defaultCatalog,defaultSchema); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                              
    22
    if (constraintString != null)
    22
    if (constraintString != null)
    19
    if (e != null)
    Differences
    Expression1Expression2Difference
    constraintStringeVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.hibernate.engine.EntityEntryVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable constraintString does not match with type org.hibernate.engine.EntityEntry of variable e
    • Make classes java.lang.String and org.hibernate.engine.EntityEntry extend a common superclass
    19
    if (e != null)
                                                                                                                                                                          
    20
    EntityKey key = new EntityKey(e.getId(), e.getPersister(), source.getEntityMode());
                                                                                      
    21
    persistenceContext.removeEntity(key);
                                                                                                    
    22
    doEvict(object, key, e.getPersister(), source);
    23
    script.add(constraintString);
                                                                      
    Precondition Violations (2)
    Row Violation
    1Unmatched statement String constraintString=uk.sqlCreateString(dialect,mapping,defaultCatalog,defaultSchema); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Type java.lang.String of variable constraintString does not match with type org.hibernate.engine.EntityEntry of variable e