final Object entity = persistenceContext.removeEntity( key ); if ( entity != null ) { EntityEntry e = event.getSession().getPersistenceContext().removeEntry( entity ); doEvict( entity, key, e.getPersister(), event.getSession() ); }
if ( id != null ) { EntityKey key = new EntityKey( id, persister, source.getEntityMode() ); Object managedEntity = source.getPersistenceContext().getEntity( key ); entry = source.getPersistenceContext().getEntry( managedEntity ); }
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/event/def/DefaultMergeEventListener.java
Method name: void onEvict(EvictEvent) Method name: boolean existsInDatabase(Object, EventSource, EntityPersister)
Number of AST nodes: 4 Number of AST nodes: 4
1
final Object entity = persistenceContext.removeEntity( key );
2
				if ( entity != null ) {
3
					EntityEntry e = event.getSession()
1
if ( id != null ) {
2
				EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
4
.getPersistenceContext().removeEntry( entity );
3
				Object managedEntity = source.getPersistenceContext().getEntity( key );
5
					doEvict( entity, key, e.getPersister(), event.getSession() );
4
				entry = source.getPersistenceContext().getEntry( managedEntity );
6
				}
5
			}
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 comparisons13
  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.1
    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
                                                                                                                              
    14
    if (entity != null)
    14
    if (entity != null)
    4
    if (id != null)
    Differences
    Expression1Expression2Difference
    entityidVARIABLE_NAME_MISMATCH
    java.lang.Objectjava.io.SerializableVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable entity does not match with type java.io.Serializable of variable id
    • Make classes java.lang.Object and java.io.Serializable extend a common superclass
    4
    if (id != null)
                                                                                                                                            
    5
    EntityKey key = new EntityKey(id, persister, source.getEntityMode());
    Preondition Violations
    Unmatched statement EntityKey key=new EntityKey(id,persister,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(id,persister,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
    5
    EntityKey key = new EntityKey(id, persister, source.getEntityMode());
                                                                                                                                                
    6
    Object managedEntity = source.getPersistenceContext().getEntity(key);
                                                                                                                                    
    7
    entry = source.getPersistenceContext().getEntry(managedEntity);
    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
                                                                                                                            
    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
    2Type java.lang.Object of variable entity does not match with type java.io.Serializable of variable id
    3Unmatched statement EntityKey key=new EntityKey(id,persister,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(id,persister,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 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
    6Unmatched 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
    7Unmatched 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
    8The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero