ParameterMetadata metadata = ( ParameterMetadata ) sqlParamMetadataCache.get( query ); if ( metadata == null ) { // for native-sql queries, the param metadata is determined outside // any relation to a query plan, because query plan creation and/or // retreival for a native-sql query depends on all of the return // types having been set, which might not be the case up-front when // param metadata would be most useful metadata = buildNativeSQLParameterMetadata( query ); sqlParamMetadataCache.put( query, metadata ); } return metadata;
NamedParameterDescription desc = ( NamedParameterDescription ) namedParameterDescriptions.get( name ); if ( desc == null ) { desc = new NamedParameterDescription( jpa ); namedParameterDescriptions.put( name, desc ); } return desc;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java
Method name: ParameterMetadata getSQLParameterMetadata(String) Method name: NamedParameterDescription getOrBuildNamedParameterDescription(String, boolean)
Number of AST nodes: 5 Number of AST nodes: 5
1
ParameterMetadata metadata = ( ParameterMetadata ) sqlParamMetadataCache.get( query );
1
NamedParameterDescription desc = ( NamedParameterDescription ) namedParameterDescriptions.get( name );
2
		if ( metadata == null ) {
2
		if ( desc == null ) {
3
			// for native-sql queries, the param metadata is determined outside
3
			
4
			// any relation to a query plan, because query plan creation and/or
5
			// retreival for a native-sql query depends on all of the return
6
			// types having been set, which might not be the case up-front when
7
			// param metadata would be most useful
8
			metadata = buildNativeSQLParameterMetadata( query );
9
			sqlParamMetadataCache.put( query, metadata
4
desc = new NamedParameterDescription( jpa );
10
 );
5
			namedParameterDescriptions.put( name, desc );
11
		}
6
		}
12
		return metadata;
7
		return desc;
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 statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                        
    1
    NamedParameterDescription desc = (NamedParameterDescription)namedParameterDescriptions.get(name);
    1
    ParameterMetadata metadata = (ParameterMetadata)sqlParamMetadataCache.get(query);
                                                                                                                                                                        
    2
    if (metadata == null)
    2
    if (metadata == null)
    2
    if (desc == null)
    Differences
    Expression1Expression2Difference
    metadatadescVARIABLE_NAME_MISMATCH
    org.hibernate.engine.query.ParameterMetadataorg.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescriptionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.engine.query.ParameterMetadata of variable metadata does not match with type org.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescription of variable desc
    • Make classes org.hibernate.engine.query.ParameterMetadata and org.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescription extend a common superclass
    2
    if (desc == null)
                                                                                          
    3
    desc = new NamedParameterDescription(jpa);
    Preondition Violations
    Unmatched statement desc=new NamedParameterDescription(jpa); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    desc = new NamedParameterDescription(jpa);
    3
    metadata = buildNativeSQLParameterMetadata(query);
    3
    metadata = buildNativeSQLParameterMetadata(query);
    Preondition Violations
    Unmatched statement metadata=buildNativeSQLParameterMetadata(query); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                          
    4
    sqlParamMetadataCache.put(query, metadata);
    4
    sqlParamMetadataCache.put(query, metadata);
    4
    namedParameterDescriptions.put(name, desc);
    Differences
    Expression1Expression2Difference
    querynameVARIABLE_NAME_MISMATCH
    metadatadescVARIABLE_NAME_MISMATCH
    org.hibernate.engine.query.ParameterMetadataorg.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescriptionVARIABLE_TYPE_MISMATCH
    sqlParamMetadataCachenamedParameterDescriptionsVARIABLE_NAME_MISMATCH
    org.hibernate.util.SimpleMRUCachejava.util.MapVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.engine.query.ParameterMetadata of variable metadata does not match with type org.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescription of variable desc
    • Make classes org.hibernate.engine.query.ParameterMetadata and org.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescription extend a common superclass
    Type org.hibernate.util.SimpleMRUCache of variable sqlParamMetadataCache does not match with type java.util.Map of variable namedParameterDescriptions
    • Make classes org.hibernate.util.SimpleMRUCache and java.util.Map extend a common superclass
    4
    namedParameterDescriptions.put(name, desc);
                                  
    5
    return desc;
    Preondition Violations
    Unmatched return desc;
    5
    return desc;
    5
    return metadata;
    5
    return metadata;
    Preondition Violations
    Unmatched return metadata;
                                          
    Precondition Violations (7)
    Row Violation
    1Type org.hibernate.engine.query.ParameterMetadata of variable metadata does not match with type org.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescription of variable desc
    2Unmatched statement desc=new NamedParameterDescription(jpa); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement metadata=buildNativeSQLParameterMetadata(query); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Type org.hibernate.engine.query.ParameterMetadata of variable metadata does not match with type org.hibernate.engine.query.ParamLocationRecognizer.NamedParameterDescription of variable desc
    5Type org.hibernate.util.SimpleMRUCache of variable sqlParamMetadataCache does not match with type java.util.Map of variable namedParameterDescriptions
    6Unmatched return desc;
    7Unmatched return metadata;