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)1.9
    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());
    Preondition Violations
    Unmatched statement EntityKey key=new EntityKey(e.getId(),e.getPersister(),source.getEntityMode()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement EntityKey key=new EntityKey(e.getId(),e.getPersister(),source.getEntityMode()); 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
    20
    EntityKey key = new EntityKey(e.getId(), e.getPersister(), source.getEntityMode());
                                                                                      
    21
    persistenceContext.removeEntity(key);
    Preondition Violations
    Unmatched statement persistenceContext.removeEntity(key); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    21
    persistenceContext.removeEntity(key);
                                                                                                    
    22
    doEvict(object, key, e.getPersister(), source);
    Preondition Violations
    Unmatched statement doEvict(object,key,e.getPersister(),source); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement doEvict(object,key,e.getPersister(),source); 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
    22
    doEvict(object, key, e.getPersister(), source);
    23
    script.add(constraintString);
    23
    script.add(constraintString);
    Preondition Violations
    Unmatched statement script.add(constraintString); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                      
    Precondition Violations (9)
    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
    3Unmatched statement EntityKey key=new EntityKey(e.getId(),e.getPersister(),source.getEntityMode()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement EntityKey key=new EntityKey(e.getId(),e.getPersister(),source.getEntityMode()); 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
    5Unmatched statement persistenceContext.removeEntity(key); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement doEvict(object,key,e.getPersister(),source); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement doEvict(object,key,e.getPersister(),source); 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 script.add(constraintString); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero