String queryCacheFactoryClassName = PropertiesHelper.getString( Environment.QUERY_CACHE_FACTORY, properties, "org.hibernate.cache.StandardQueryCacheFactory" ); log.info("Query cache factory: " + queryCacheFactoryClassName); try { return (QueryCacheFactory) ReflectHelper.classForName(queryCacheFactoryClassName).newInstance(); } catch (Exception cnfe) { throw new HibernateException("could not instantiate QueryCacheFactory: " + queryCacheFactoryClassName, cnfe); }
String className = PropertiesHelper.getString( Environment.QUERY_TRANSLATOR, properties, "org.hibernate.hql.ast.ASTQueryTranslatorFactory" ); log.info("Query translator: " + className); try { return (QueryTranslatorFactory) ReflectHelper.classForName(className).newInstance(); } catch (Exception cnfe) { throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, cnfe); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/SettingsFactory.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
Method name: QueryCacheFactory createQueryCacheFactory(Properties) Method name: QueryTranslatorFactory createQueryTranslatorFactory(Properties)
Number of AST nodes: 4 Number of AST nodes: 4
1
String queryCacheFactoryClassName = PropertiesHelper.getString(
1
String className = PropertiesHelper.getString(
2
				Environment.QUERY_CACHE_FACTORY, properties, "org.hibernate.cache.StandardQueryCacheFactory"
2
				Environment.QUERY_TRANSLATOR, properties, "org.hibernate.hql.ast.ASTQueryTranslatorFactory"
3
		);
3
		);
4
		log.info("Query cache factory: " + queryCacheFactoryClassName);
4
		log.info("Query translator: " + className);
5
		try {
5
		try {
6
			return (QueryCacheFactory) ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();
6
			return (QueryTranslatorFactory) ReflectHelper.classForName(className).newInstance();
7
		}
7
		}
8
		catch (Exception cnfe) {
8
		catch (Exception cnfe) {
9
			throw new HibernateException("could not instantiate QueryCacheFactory: " + queryCacheFactoryClassName, cnfe);
9
			throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, cnfe);
10
		}
10
		}
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 declared in the same class
Number of node comparisons8
  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)1.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    String queryCacheFactoryClassName = PropertiesHelper.getString(Environment.QUERY_CACHE_FACTORY, properties, "org.hibernate.cache.StandardQueryCacheFactory");
    1
    String queryCacheFactoryClassName = PropertiesHelper.getString(Environment.QUERY_CACHE_FACTORY, properties, "org.hibernate.cache.StandardQueryCacheFactory");
    1
    String className = PropertiesHelper.getString(Environment.QUERY_TRANSLATOR, properties, "org.hibernate.hql.ast.ASTQueryTranslatorFactory");
    Differences
    Expression1Expression2Difference
    queryCacheFactoryClassNameclassNameVARIABLE_NAME_MISMATCH
    QUERY_CACHE_FACTORYQUERY_TRANSLATORVARIABLE_NAME_MISMATCH
    "org.hibernate.cache.StandardQueryCacheFactory""org.hibernate.hql.ast.ASTQueryTranslatorFactory"LITERAL_VALUE_MISMATCH
    1
    String className = PropertiesHelper.getString(Environment.QUERY_TRANSLATOR, properties, "org.hibernate.hql.ast.ASTQueryTranslatorFactory");
    2
    log.info("Query cache factory: " + queryCacheFactoryClassName);
    2
    log.info("Query cache factory: " + queryCacheFactoryClassName);
    2
    log.info("Query translator: " + className);
    Differences
    Expression1Expression2Difference
    "Query cache factory: ""Query translator: "LITERAL_VALUE_MISMATCH
    queryCacheFactoryClassNameclassNameVARIABLE_NAME_MISMATCH
    2
    log.info("Query translator: " + className);
    3
    try
    3
    try
    3
    try
    Differences
    Expression1Expression2Difference
    "could not instantiate QueryCacheFactory: ""could not instantiate QueryTranslatorFactory: "LITERAL_VALUE_MISMATCH
    queryCacheFactoryClassNameclassNameVARIABLE_NAME_MISMATCH
    3
    try
                                                                                                                                                                                
    4
    return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance();
    Preondition Violations
    Unmatched statement return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance(); 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 return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance();
    4
    return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance();
    4
    return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();
    4
    return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();
    Preondition Violations
    Unmatched statement return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance(); 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 return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();
                                                                                                                                                                                                        
    Precondition Violations (6)
    Row Violation
    1Unmatched statement return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance(); 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
    3Unmatched return (QueryTranslatorFactory)ReflectHelper.classForName(className).newInstance();
    4Unmatched statement return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance(); 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
    6Unmatched return (QueryCacheFactory)ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();