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.collectionInfoString(p, id, this) ); } CacheKey cacheKey = new CacheKey( id, p.getKeyType(), p.getRole(), 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 evictCollection(String, 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 );
3
				if ( isEqual ) {
4
					throw new PersistentObjectException(
5
							"object passed to save() was already persistent: " +
6
									
1
if ( log.isDebugEnabled() ) {
7
MessageHelper.infoString( entityEntry.getPersister(), requestedId, factory )
2
				log.debug( "evicting second-level cache: " + MessageHelper.
8
					);
9
				}
10
				savedId = requestedId
3
collectionInfoString(p, id, this) );
4
			}
5
			CacheKey cacheKey = new CacheKey( id, p.getKeyType(), p.getRole(), 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.1
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)4.0
    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
    Preondition Violations
    Expression isEqual cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    if (log.isDebugEnabled())
                                                                                                                                                                                                
    4
    log.debug("evicting second-level cache: " + MessageHelper.collectionInfoString(p, id, this));
    Preondition Violations
    Unmatched statement log.debug("evicting second-level cache: " + MessageHelper.collectionInfoString(p,id,this)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    log.debug("evicting second-level cache: " + MessageHelper.collectionInfoString(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 statement throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(),requestedId,factory)); 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
    Unmatched throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(),requestedId,factory));
                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                
    5
    CacheKey cacheKey = new CacheKey(id, p.getKeyType(), p.getRole(), EntityMode.POJO, this);
    Preondition Violations
    Unmatched statement CacheKey cacheKey=new CacheKey(id,p.getKeyType(),p.getRole(),EntityMode.POJO,this); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    CacheKey cacheKey = new CacheKey(id, p.getKeyType(), p.getRole(), EntityMode.POJO, this);
                                                                                                
    6
    p.getCacheAccessStrategy().evict(cacheKey);
    15
    savedId = requestedId;
                                                    
    Precondition Violations (6)
    Row Violation
    1Expression isEqual cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Unmatched statement log.debug("evicting second-level cache: " + MessageHelper.collectionInfoString(p,id,this)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(),requestedId,factory)); 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
    4Unmatched throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.infoString(entityEntry.getPersister(),requestedId,factory));
    5Unmatched statement CacheKey cacheKey=new CacheKey(id,p.getKeyType(),p.getRole(),EntityMode.POJO,this); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero