final boolean isEqual = !entityEntry.getPersister().getIdentifierType() .isEqual( requestedId, entityEntry.getId(), event.getSession().getEntityMode(), factory ); if ( isEqual ) { throw new PersistentObjectException( "object passed to save() was already persistent: " + MessageHelper.infoString( entityEntry.getPersister(), requestedId, factory ) ); } savedId = requestedId;
if ( log.isDebugEnabled() ) { log.debug( "evicting second-level cache: " + MessageHelper.infoString(p, id, this) ); } CacheKey cacheKey = new CacheKey( id, p.getIdentifierType(), p.getRootEntityName(), EntityMode.POJO, this ); p.getCacheAccessStrategy().evict( cacheKey );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/event/def/DefaultSaveOrUpdateEventListener.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
Method name: Serializable entityIsPersistent(SaveOrUpdateEvent) Method name: void evict(Class, Serializable)
Number of AST nodes: 4 Number of AST nodes: 4
1
final boolean isEqual = !entityEntry.getPersister().getIdentifierType()
2
						.isEqual( requestedId, entityEntry.getId(), event.getSession().getEntityMode(), factory
1
if ( log.isDebugEnabled() ) {
3
 );
2
				log.debug( "evicting second-level cache: " + MessageHelper.infoString(p, id, this) );
4
				if ( isEqual ) {
3
			
5
					throw new PersistentObjectException(
6
							"object passed to save() was already persistent: " +
7
									MessageHelper.infoString( entityEntry.getPersister(), requestedId, factory )
8
					);
9
				}
10
				savedId = requestedId
4
}
5
			CacheKey cacheKey = new CacheKey( id, p.getIdentifierType(), p.getRootEntityName(), EntityMode.POJO, this );
11
;
6
			p.getCacheAccessStrategy().evict( cacheKey );
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 comparisons8
  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)3.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    12
    final boolean isEqual = !entityEntry.getPersister().getIdentifierType().isEqual(requestedId, entityEntry.getId(), event.getSession().getEntityMode(), factory);
                                                                                                                                                                                                                                                                                                                                
    13
    if (isEqual)
    13
    if (isEqual)
    3
    if (log.isDebugEnabled())
    Differences
    Expression1Expression2Difference
    isEquallog.isDebugEnabled()TYPE_COMPATIBLE_REPLACEMENT
    3
    if (log.isDebugEnabled())
                                                                                                                                                                            
    4
    log.debug("evicting second-level cache: " + MessageHelper.infoString(p, id, this));
    14
    throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(), requestedId, factory));
    14
    throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(), requestedId, factory));
    Preondition Violations
    Unmatched throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(),requestedId,factory));
                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                  
    5
    CacheKey cacheKey = new CacheKey(id, p.getIdentifierType(), p.getRootEntityName(), EntityMode.POJO, this);
                                                                                                
    6
    p.getCacheAccessStrategy().evict(cacheKey);
    15
    savedId = requestedId;
                                                    
    Precondition Violations (1)
    Row Violation
    1Unmatched throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(),requestedId,factory));