/** * Locate a registered sql function by name. * * @param functionName The name of the function to locate * * @return The sql function, or null if not found. */ public SQLFunction findSQLFunction(String functionName) { return sfi.getSqlFunctionRegistry().findSQLFunction( functionName ); }
/** * Same functionality as {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)}, * except that a SQLFunctionRegistry is not provided (i.e., only the dialect-defined functions are * considered). This is only intended for use by the annotations project until the * many-to-many/map-key-from-target-table feature is pulled into core. * * @deprecated Only intended for annotations usage; use {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)} instead */ @Deprecated @SuppressWarnings({ "JavaDoc" }) public static String renderWhereStringTemplate(String sqlWhereString, String placeholder, Dialect dialect) { return renderWhereStringTemplate( sqlWhereString, placeholder, dialect, new SQLFunctionRegistry( dialect, java.util.Collections.<String, SQLFunction>emptyMap() ) ); }
private static boolean isFunction(String lcToken, String nextToken, SQLFunctionRegistry functionRegistry) { // checking for "(" is currently redundant because it is checked before getting here; // doing the check anyhow, in case that earlier check goes away; if ( "(".equals( nextToken ) ) { return true; } SQLFunction function = functionRegistry.findSQLFunction(lcToken); if ( function == null ) { // lcToken does not refer to a function return false; } // if function.hasParenthesesIfNoArguments() is true, then assume // lcToken is not a function (since it is not followed by '(') return ! function.hasParenthesesIfNoArguments(); }
logIfEmptyCompositesEnabled( this.properties ); this.sqlFunctionRegistry = new SQLFunctionRegistry( jdbcServices.getJdbcEnvironment().getDialect(), options.getCustomSqlFunctionMap() ); this.cacheAccess = this.serviceRegistry.getService( CacheImplementor.class ); this.criteriaBuilder = new CriteriaBuilderImpl( this );
private SQLFunction getFunction(String name, QueryTranslatorImpl q) { return q.getFactory().getSqlFunctionRegistry().findSQLFunction( name ); }
/** * Same functionality as {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)}, * except that a SQLFunctionRegistry is not provided (i.e., only the dialect-defined functions are * considered). This is only intended for use by the annotations project until the * many-to-many/map-key-from-target-table feature is pulled into core. * * @deprecated Only intended for annotations usage; use {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)} instead */ @Deprecated @SuppressWarnings({ "JavaDoc" }) public static String renderWhereStringTemplate(String sqlWhereString, String placeholder, Dialect dialect) { return renderWhereStringTemplate( sqlWhereString, placeholder, dialect, new SQLFunctionRegistry( dialect, java.util.Collections.EMPTY_MAP ) ); }
protected SQLFunction getFunction(CriteriaQuery criteriaQuery) { final SQLFunctionRegistry sqlFunctionRegistry = criteriaQuery.getFactory().getSqlFunctionRegistry(); final SQLFunction function = sqlFunctionRegistry.findSQLFunction( "count" ); if ( function == null ) { throw new HibernateException( "Unable to locate count function mapping" ); } return function; }
/** * Same functionality as {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)}, * except that a SQLFunctionRegistry is not provided (i.e., only the dialect-defined functions are * considered). This is only intended for use by the annotations project until the * many-to-many/map-key-from-target-table feature is pulled into core. * * @deprecated Only intended for annotations usage; use {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)} instead */ @Deprecated @SuppressWarnings({ "JavaDoc" }) public static String renderWhereStringTemplate(String sqlWhereString, String placeholder, Dialect dialect) { return renderWhereStringTemplate( sqlWhereString, placeholder, dialect, new SQLFunctionRegistry( dialect, java.util.Collections.EMPTY_MAP ) ); }
protected SQLFunction getFunction(String functionName, CriteriaQuery criteriaQuery) { final SQLFunction function = criteriaQuery.getFactory() .getSqlFunctionRegistry() .findSQLFunction( functionName ); if ( function == null ) { throw new HibernateException( "Unable to locate mapping for function named [" + functionName + "]" ); } return function; }
/** * Same functionality as {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)}, * except that a SQLFunctionRegistry is not provided (i.e., only the dialect-defined functions are * considered). This is only intended for use by the annotations project until the * many-to-many/map-key-from-target-table feature is pulled into core. * * @deprecated Only intended for annotations usage; use {@link #renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry)} instead */ @Deprecated @SuppressWarnings({ "JavaDoc" }) public static String renderWhereStringTemplate(String sqlWhereString, String placeholder, Dialect dialect) { return renderWhereStringTemplate(sqlWhereString, placeholder, dialect, new SQLFunctionRegistry(dialect, java.util.Collections.<String, SQLFunction> emptyMap())); }
@Override @SuppressWarnings("SimplifiableIfStatement") protected boolean isFunctionName(AST ast) { /* * Semantic predicate used to determine whether a given AST node represents a function call */ AST child = ast.getFirstChild(); // assume it is a function if it has parameters if ( child != null && "{param list}".equals( child.getText() ) ) { return true; } // otherwise, in order for this to be a function logically it has to be a function that does not // have arguments. So try to assert that using the registry of known functions final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() ); if ( function == null ) { // no registered function, so we cannot know for certain return false; } else { // if function.hasParenthesesIfNoArguments() is true, then assume the node is not a function return !function.hasParenthesesIfNoArguments(); } }
this.jdbcServices = this.serviceRegistry.getService( JdbcServices.class ); this.dialect = this.jdbcServices.getDialect(); this.sqlFunctionRegistry = new SQLFunctionRegistry( getDialect(), cfg.getSqlFunctions() ); if ( observer != null ) { this.observer.addObserver( observer );
final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( functionName ); if ( function == null ) { String text = functionName;
this.jdbcServices = this.serviceRegistry.getService( JdbcServices.class ); this.dialect = this.jdbcServices.getDialect(); this.sqlFunctionRegistry = new SQLFunctionRegistry( getDialect(), cfg.getSqlFunctions() ); if ( observer != null ) { this.observer.addObserver( observer );
@Test public void testNoArgFcnAndColumnSameNameAsNoArgFunctionHQL() { SQLFunction function = sessionFactory().getSqlFunctionRegistry().findSQLFunction( "current_date" ); if ( function == null || function.hasParenthesesIfNoArguments() ) { SkipLog.reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
this.sqlFunctionRegistry = new SQLFunctionRegistry( this.dialect, new HashMap<String, SQLFunction>() );
@Test public void testGetMultiColumnSameNameAsNoArgFunctionHQL() throws Exception { SQLFunction function = sessionFactory().getSqlFunctionRegistry().findSQLFunction( "current_date" ); if ( function == null || function.hasParenthesesIfNoArguments() ) { SkipLog.reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
this.sqlFunctionRegistry = new SQLFunctionRegistry( this.dialect, new HashMap<String, SQLFunction>() );
@Test public void testGetMultiColumnSameNameAsNoArgFunctionCriteria() { SQLFunction function = sessionFactory().getSqlFunctionRegistry().findSQLFunction( "current_date" ); if ( function == null || function.hasParenthesesIfNoArguments() ) { SkipLog.reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
/** * Locate a registered sql function by name. * * @param functionName The name of the function to locate * @return The sql function, or null if not found. */ public SQLFunction findSQLFunction(String functionName) { return sfi.getSqlFunctionRegistry().findSQLFunction( functionName.toLowerCase() ); }