if ( !li.isUninitialized() ) { final Object entity = persistenceContext.removeEntity( key ); if ( entity != null ) { EntityEntry e = event.getSession().getPersistenceContext().removeEntry( entity ); doEvict( entity, key, e.getPersister(), event.getSession() ); } }
if ( dialect.supportsUniqueConstraintInCreateAlterTable() ) { Iterator ukiter = getUniqueKeyIterator(); while ( ukiter.hasNext() ) { UniqueKey uk = (UniqueKey) ukiter.next(); String constraint = uk.sqlConstraintString( dialect ); if ( constraint != null ) { buf.append( ", " ).append( constraint ); } } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/event/def/DefaultEvictEventListener.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/mapping/Table.java
Method name: void onEvict(EvictEvent) Method name: String sqlCreateString(Dialect, Mapping, String, String)
Number of AST nodes: 5 Number of AST nodes: 7
1
if ( !li.isUninitialized() ) {
1
if ( 
2
				final Object entity = persistenceContext.removeEntity( key );
3
				if ( entity != null ) {
4
					EntityEntry e = event.getSession().getPersistenceContext().removeEntry( entity );
5
					doEvict( entity, key, e.getPersister(), event.getSession()
2
dialect.supportsUniqueConstraintInCreateAlterTable() ) {
3
			Iterator ukiter = getUniqueKeyIterator();
4
			while ( ukiter.hasNext() ) {
5
				UniqueKey uk = (UniqueKey) ukiter.next();
6
				String constraint = uk.sqlConstraintString( dialect );
7
				if ( constraint != null ) {
6
 );
8
					buf.append( ", " ).append( constraint );
7
				}
9
				}
8
			}
10
			}
11
		}
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 comparisons9
  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 fragment3
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    13
    final Object entity = persistenceContext.removeEntity(key);
    13
    final Object entity = persistenceContext.removeEntity(key);
    Preondition Violations
    Unmatched statement final Object entity=persistenceContext.removeEntity(key); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                              
                                                                                        
    39
    UniqueKey uk = (UniqueKey)ukiter.next();
                                                                                                                
    40
    String constraint = uk.sqlConstraintString(dialect);
    Preondition Violations
    Unmatched statement String constraint=uk.sqlConstraintString(dialect); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    40
    String constraint = uk.sqlConstraintString(dialect);
    14
    if (entity != null)
    14
    if (entity != null)
    41
    if (constraint != null)
    Differences
    Expression1Expression2Difference
    entityconstraintVARIABLE_NAME_MISMATCH
    java.lang.Objectjava.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable entity does not match with type java.lang.String of variable constraint
    • Make classes java.lang.Object and java.lang.String extend a common superclass
    41
    if (constraint != null)
    15
    EntityEntry e = event.getSession().getPersistenceContext().removeEntry(entity);
    15
    EntityEntry e = event.getSession().getPersistenceContext().removeEntry(entity);
    Preondition Violations
    Unmatched statement EntityEntry e=event.getSession().getPersistenceContext().removeEntry(entity); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                      
    16
    doEvict(entity, key, e.getPersister(), event.getSession());
    16
    doEvict(entity, key, e.getPersister(), event.getSession());
    Preondition Violations
    Unmatched statement doEvict(entity,key,e.getPersister(),event.getSession()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement doEvict(entity,key,e.getPersister(),event.getSession()); 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
                                                                                                                            
                                                                                    
    42
    buf.append(", ").append(constraint);
    Preondition Violations
    Unmatched statement buf.append(", ").append(constraint); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    42
    buf.append(", ").append(constraint);
    Precondition Violations (8)
    Row Violation
    1Unmatched statement final Object entity=persistenceContext.removeEntity(key); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement String constraint=uk.sqlConstraintString(dialect); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type java.lang.Object of variable entity does not match with type java.lang.String of variable constraint
    4Unmatched statement EntityEntry e=event.getSession().getPersistenceContext().removeEntry(entity); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement doEvict(entity,key,e.getPersister(),event.getSession()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement doEvict(entity,key,e.getPersister(),event.getSession()); 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
    7Unmatched statement buf.append(", ").append(constraint); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero