Package org.hibernate.dialect.function

Examples of org.hibernate.dialect.function.SQLFunction


   * @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

   * @param functionName The name of the function to locate
   * @return The sql function.
   * @throws QueryException Indicates no matching sql functions could be found.
   */
  private SQLFunction requireSQLFunction(String functionName) {
    SQLFunction f = findSQLFunction( functionName );
    if ( f == null ) {
      throw new QueryException( "Unable to find SQL function: " + functionName );
    }
    return f;
  }
View Full Code Here

   * @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) {
    // locate the registered function by the given name
    SQLFunction sqlFunction = requireSQLFunction( functionName );

    // determine the type of the first argument...
    Type argumentType = null;
    if ( first != null ) {
      if ( "cast".equals(functionName) ) {
        argumentType = TypeFactory.heuristicType( first.getNextSibling().getText() );
      }
      else if ( first instanceof SqlNode ) {
        argumentType = ( (SqlNode) first ).getDataType();
      }
    }

    return sqlFunction.getReturnType( argumentType, sfi );
  }
View Full Code Here

    }
  }

  protected void beginFunctionTemplate(AST m, AST i) {
    MethodNode methodNode = ( MethodNode ) m;
    SQLFunction template = methodNode.getSQLFunction();
    if ( template == null ) {
      // if template is null we just write the function out as it appears in the hql statement
      super.beginFunctionTemplate( m, i );
    }
    else {
View Full Code Here

    }
  }

  protected void endFunctionTemplate(AST m) {
    MethodNode methodNode = ( MethodNode ) m;
    SQLFunction template = methodNode.getSQLFunction();
    if ( template == null ) {
      super.endFunctionTemplate( m );
    }
    else {
      // this function has a template -> restore output, apply the template and write the result out
      FunctionArguments functionArguments = ( FunctionArguments ) writer;   // TODO: Downcast to avoid using an interface?  Yuck.
      writer = ( SqlWriter ) outputStack.removeFirst();
      out( template.render( functionArguments.getArgs(), sessionFactory ) );
    }
  }
View Full Code Here

  public Type getDataType() {
    Type type = super.getDataType();
    if (type != null) return type;
    FromElement fe = getFromElement();
    if (fe != null) return fe.getDataType();
    SQLFunction sf = getWalker().getSessionFactoryHelper().findSQLFunction(getText());
    return sf == null ? null : sf.getReturnType(null, null);
  }
View Full Code Here

    }
  }

  protected void beginFunctionTemplate(AST m, AST i) {
    MethodNode methodNode = ( MethodNode ) m;
    SQLFunction template = methodNode.getSQLFunction();
    if ( template == null ) {
      // if template is null we just write the function out as it appears in the hql statement
      super.beginFunctionTemplate( m, i );
    }
    else {
View Full Code Here

    }
  }

  protected void endFunctionTemplate(AST m) {
    MethodNode methodNode = ( MethodNode ) m;
    SQLFunction template = methodNode.getSQLFunction();
    if ( template == null ) {
      super.endFunctionTemplate( m );
    }
    else {
      // this function has a template -> restore output, apply the template and write the result out
      FunctionArguments functionArguments = ( FunctionArguments ) writer;   // TODO: Downcast to avoid using an interface?  Yuck.
      writer = ( SqlWriter ) outputStack.removeFirst();
      out( template.render( functionArguments.getArgs(), sessionFactory ) );
    }
  }
View Full Code Here

    }
  }

  protected void beginFunctionTemplate(AST m, AST i) {
    MethodNode methodNode = ( MethodNode ) m;
    SQLFunction template = methodNode.getSQLFunction();
    if ( template == null ) {
      // if template is null we just write the function out as it appears in the hql statement
      super.beginFunctionTemplate( m, i );
    }
    else {
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.