final Object entity = persistenceContext.removeEntity( key ); if ( entity != null ) { EntityEntry e = event.getSession().getPersistenceContext().removeEntry( entity ); doEvict( entity, key, e.getPersister(), event.getSession() ); }
final EntityKey key = new EntityKey( getIdentifier(), session.getFactory().getEntityPersister( getEntityName() ), session.getEntityMode() ); final Object entity = session.getPersistenceContext().getEntity(key); if (entity!=null) setImplementation( entity );
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/proxy/pojo/BasicLazyInitializer.java
Method name: void onEvict(EvictEvent) Method name: Object getReplacement()
Number of AST nodes: 4 Number of AST nodes: 4
1
final Object entity = persistenceContext.removeEntity( key
1
final EntityKey key = new EntityKey(
2
					getIdentifier(),
2
 );
3
			        session.getFactory().getEntityPersister( getEntityName() ),
3
				if ( entity != null ) {
4
			
4
					EntityEntry e = event.getS
5
        session.getEntityMode()
6
				);
5
ession().getPersistenceContext().removeEntry( entity );
7
			final Object entity = session.getPersistenceContext().getEntity(key);
6
					doEvict( entity, key, e.getPersister(), event.getSession() );
8
			
7
				}
9
if (entity!=null) setImplementation( entity );
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.2
Clones locationClones are in different classes
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)120.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                                                                                                  
    3
    final EntityKey key = new EntityKey(getIdentifier(), session.getFactory().getEntityPersister(getEntityName()), session.getEntityMode());
    13
    final Object entity = persistenceContext.removeEntity(key);
    13
    final Object entity = persistenceContext.removeEntity(key);
    4
    final Object entity = session.getPersistenceContext().getEntity(key);
    Differences
    Expression1Expression2Difference
    removeEntitygetEntityMETHOD_INVOCATION_NAME_MISMATCH
    persistenceContextsession.getPersistenceContext()TYPE_COMPATIBLE_REPLACEMENT
    4
    final Object entity = session.getPersistenceContext().getEntity(key);
    14
    if (entity != null)
    5
    if (entity != 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 or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                      
    16
    doEvict(entity, key, e.getPersister(), event.getSession());
    16
    doEvict(entity, key, e.getPersister(), event.getSession());
    6
    setImplementation(entity);
    Differences
    Expression1Expression2Difference
    doEvictsetImplementationMETHOD_INVOCATION_NAME_MISMATCH
    doEvict(entity,key,e.getPersister(),event.getSession())setImplementation(entity)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression doEvict(entity,key,e.getPersister(),event.getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression setImplementation(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression doEvict(entity,key,e.getPersister(),event.getSession()) is a void method call, and thus it cannot be parameterized
    Expression setImplementation(entity) is a void method call, and thus it cannot be parameterized
    Expression doEvict(entity,key,e.getPersister(),event.getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression setImplementation(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression doEvict(entity,key,e.getPersister(),event.getSession()) is a void method call, and thus it cannot be parameterized
    Expression setImplementation(entity) is a void method call, and thus it cannot be parameterized
    6
    setImplementation(entity);
    Precondition Violations (10)
    Row Violation
    1Unmatched statement EntityEntry e=event.getSession().getPersistenceContext().removeEntry(entity); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression doEvict(entity,key,e.getPersister(),event.getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression setImplementation(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression doEvict(entity,key,e.getPersister(),event.getSession()) is a void method call, and thus it cannot be parameterized
    5Expression setImplementation(entity) is a void method call, and thus it cannot be parameterized
    6Expression doEvict(entity,key,e.getPersister(),event.getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression setImplementation(entity) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression doEvict(entity,key,e.getPersister(),event.getSession()) is a void method call, and thus it cannot be parameterized
    9Expression setImplementation(entity) is a void method call, and thus it cannot be parameterized
    10Clone fragment #1 returns variables entity , while Clone fragment #2 returns variables