Package org.hibernate.dialect.function

Examples of org.hibernate.dialect.function.SQLFunction


   * @param functionName The function name.
   * @param first        The first argument expression.
   * @return the function return type given the function name and the first argument expression node.
   */
  public Type findFunctionReturnType(String functionName, AST first) {
    SQLFunction sqlFunction = requireSQLFunction( functionName );
    return findFunctionReturnType( functionName, sqlFunction, first );
  }
View Full Code Here


    }
    FromElement fe = getFromElement();
    if ( fe != null ) {
      return fe.getDataType();
    }
    SQLFunction sf = getWalker().getSessionFactoryHelper().findSQLFunction( getText() );
    if ( sf != null ) {
      return sf.getReturnType( null, getWalker().getSessionFactoryHelper().getFactory() );
    }
    return null;
  }
View Full Code Here

  @Override
    protected void beginFunctionTemplate(AST node, AST nameNode) {
    // NOTE for AGGREGATE both nodes are the same; for METHOD the first is the METHOD, the second is the
    //     METHOD_NAME
    FunctionNode functionNode = ( FunctionNode ) node;
    SQLFunction sqlFunction = functionNode.getSQLFunction();
    if ( sqlFunction == null ) {
      // if SQLFunction is null we just write the function out as it appears in the hql statement
      super.beginFunctionTemplate( node, nameNode );
    }
    else {
View Full Code Here

  }

  @Override
    protected void endFunctionTemplate(AST node) {
    FunctionNode functionNode = ( FunctionNode ) node;
    SQLFunction sqlFunction = functionNode.getSQLFunction();
    if ( sqlFunction == null ) {
      super.endFunctionTemplate( node );
    }
    else {
      final Type functionType = functionNode.getFirstArgumentType();
      // this function has a registered SQLFunction -> redirect output and catch the arguments
      FunctionArguments functionArguments = ( FunctionArguments ) writer;
      writer = outputStack.removeFirst();
      out( sqlFunction.render( functionType, functionArguments.getArgs(), sessionFactory ) );
    }
  }
View Full Code Here

  protected SQLFunction getFunction(CriteriaQuery criteriaQuery) {
    return getFunction( getFunctionName(), criteriaQuery );
  }

  protected SQLFunction getFunction(String functionName, CriteriaQuery criteriaQuery) {
    SQLFunction function = criteriaQuery.getFactory()
        .getSqlFunctionRegistry()
        .findSQLFunction( functionName );
    if ( function == null ) {
      throw new HibernateException( "Unable to locate mapping for function named [" + functionName + "]" );
    }
View Full Code Here

    // assume it is a function if it has parameters
    if ( child != null && "{param list}".equals( child.getText() ) ) {
      return true;
    }

    final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() );
    if ( function == null ) {
      return false;
    }

    // if function.hasParenthesesIfNoArguments() is true, then assume
    // ast.getText() is not a function.
    return ! function.hasParenthesesIfNoArguments();
  }
View Full Code Here

      assert "{param list}".equalschild.getText() );
      child = child.getFirstChild();
    }

    final String functionName = ast.getText();
    final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( functionName );
    if ( function == null ) {
      String text = functionName;
      if ( child != null ) {
        text += '(';
        while ( child != null ) {
          text += child.getText();
          child = child.getNextSibling();
          if ( child != null ) {
            text += ", ";
          }
        }
        text += ')';
      }
      return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, text );
    }
    else {
      ArrayList expressions = new ArrayList();
      while ( child != null ) {
        expressions.add( child.getText() );
        child = child.getNextSibling();
      }
      final String text = function.render( null, expressions, context.getSessionFactory() );
      return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, text );
    }
  }
View Full Code Here

    return getFunction( criteriaQuery ).render( null, ARGS, criteriaQuery.getFactory() )
        + " as y" + position + '_';
  }

  protected SQLFunction getFunction(CriteriaQuery criteriaQuery) {
    SQLFunction function = criteriaQuery.getFactory()
        .getSqlFunctionRegistry()
        .findSQLFunction( "count" );
    if ( function == null ) {
      throw new HibernateException( "Unable to locate count function mapping" );
    }
View Full Code Here

      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();
    }
  }
View Full Code Here

      assert "{param list}".equalschild.getText() );
      child = child.getFirstChild();
    }

    final String functionName = ast.getText();
    final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( functionName );
    if ( function == null ) {
      String text = functionName;
      if ( child != null ) {
        text += '(';
        while ( child != null ) {
          text += resolveFunctionArgument( child );
          child = child.getNextSibling();
          if ( child != null ) {
            text += ", ";
          }
        }
        text += ')';
      }
      return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, text );
    }
    else {
      ArrayList expressions = new ArrayList();
      while ( child != null ) {
        expressions.add( resolveFunctionArgument( child ) );
        child = child.getNextSibling();
      }
      final String text = function.render( null, expressions, context.getSessionFactory() );
      return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, text );
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.dialect.function.SQLFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.