Example usage for org.hibernate.internal.util.config ConfigurationHelper resolvePlaceHolder

List of usage examples for org.hibernate.internal.util.config ConfigurationHelper resolvePlaceHolder

Introduction

In this page you can find the example usage for org.hibernate.internal.util.config ConfigurationHelper resolvePlaceHolder.

Prototype

public static String resolvePlaceHolder(String property) 

Source Link

Document

Handles interpolation processing for a single property.

Usage

From source file:org.squashtest.tm.service.internal.hibernate.SquashEntityManagerFactoryBuilderImpl.java

License:Open Source License

/**
 * Returns the extensions required by our supported dialects. As of Squash 1.13 extensions are : 
 * //from   w  w  w  .jav a2 s  .c o  m
 * <ul>
 *    <li>Postgresql : 
 *       <ul>
 *          <li>string_aggr : maps our HQL version of group_concat to postgresql string_aggr</li>
 *          <li>extract_week : maps native HQL week(timestamp) to postgresql extract(week from timestamp) because Hibernate won't</li>
 *       </ul>
 *    </li>
 *    <li>Mysql, H2 :
 *       <ul>
 *          <li>group_concat : just maps our HQL version of group_concat to group_concat (same name in both database)</li>
 *       </ul>
 *    </li>
 *    <li>
 *    <li>default (for not officially supported DBs) : 
 *       <ul>
 *          <li>group_concat : a short in the dark and hope that function group_concat exists in the end target</li>
 *       </ul>
 * </li>
 * </ul>
 * 
 * @param dialectProp value of the dialect Hibernate property
 */

private FnSupport[] configureFunctionSupport(String dialectProp) {
    String dialect = ConfigurationHelper.resolvePlaceHolder(StringUtils.defaultString(dialectProp))
            .toLowerCase();

    if (StringUtils.contains(dialect, "postgresql")) {
        return new FnSupport[] { STR_AGG, EXTRACT_WEEK };
    } else {
        if (!StringUtils.contains(dialect, "h2") && !StringUtils.contains(dialect, "mysql")) {
            LOGGER.warn(
                    "Selected hibernate Dialect '{}' is not known to support the sql function 'group_concat()'. Application will certainly not properly work. Maybe you configured a wrong dialect ?",
                    dialectProp);
        }

        return new FnSupport[] { GROUP_CONCAT };
    }
}