Package org.hibernate.dialect.function

Examples of org.hibernate.dialect.function.SQLFunction.render()


      f.setFormula( "extract( year from dob )");
    }
    else {
      List args = new ArrayList();
      args.add( "dob" );
      f.setFormula( yearFunction.render( args, null ) );
    }
  }
 
  public void testUpdateFalse() {
    getSessions().getStatistics().clear();
View Full Code Here


    assertTranslation( "from Animal an where an.bodyWeight > abs(3/5)" );
    assertTranslation( "from Animal an where an.bodyWeight > abs(3+5)" );
    assertTranslation( "from Animal an where an.bodyWeight > abs(3*5)" );
    SQLFunction concat = getSessionFactoryImplementor().getSqlFunctionRegistry().findSQLFunction( "concat");
    List list = new ArrayList(); list.add("'fat'"); list.add("'skinny'");
    assertTranslation( "from Animal an where an.description = " + concat.render(list, getSessionFactoryImplementor()) );
  }

  public void testNotOrWhereClause() {
    assertTranslation( "from Simple s where 'foo'='bar' or not 'foo'='foo'" );
    assertTranslation( "from Simple s where 'foo'='bar' or not ('foo'='foo')" );
View Full Code Here

    else {
      final Type functionType = functionNode.getFirstArgumentType();
      // this function has a registered SQLFunction -> redirect output and catch the arguments
      FunctionArgumentsCollectingWriter functionArguments = (FunctionArgumentsCollectingWriter) writer;
      writer = outputStack.removeFirst();
      out( sqlFunction.render( functionType, functionArguments.getArgs(), sessionFactory ) );
    }
  }

  // --- Inner classes (moved here from sql-gen.g) ---
View Full Code Here

    }
    else {
      // this function has a registered SQLFunction -> redirect output and catch the arguments
      FunctionArguments functionArguments = ( FunctionArguments ) writer;
      writer = outputStack.removeFirst();
      out( sqlFunction.render( functionArguments.getArgs(), sessionFactory ) );
    }
  }

  // --- Inner classes (moved here from sql-gen.g) ---
View Full Code Here

    assertTranslation( "from Animal an where an.bodyWeight > abs(3/5)" );
    assertTranslation( "from Animal an where an.bodyWeight > abs(3+5)" );
    assertTranslation( "from Animal an where an.bodyWeight > abs(3*5)" );
    SQLFunction concat = getSessionFactoryImplementor().getSqlFunctionRegistry().findSQLFunction( "concat");
    List list = new ArrayList(); list.add("'fat'"); list.add("'skinny'");
    assertTranslation( "from Animal an where an.description = " + concat.render(list, getSessionFactoryImplementor()) );
  }

  public void testNotOrWhereClause() {
    assertTranslation( "from Simple s where 'foo'='bar' or not 'foo'='foo'" );
    assertTranslation( "from Simple s where 'foo'='bar' or not ('foo'='foo')" );
View Full Code Here

    super( x );
  }

  public void testNativeQueryWithFormulaAttribute() {
    SQLFunction dateFunction = getDialect().getFunctions().get( "current_date" );
    String dateFunctionRendered = dateFunction.render(
        java.util.Collections.EMPTY_LIST,
        (SessionFactoryImplementor)getSessions()
    );

    String sql = String.format(
View Full Code Here

      f.setFormula( "extract( year from dob )");
    }
    else {
      List args = new ArrayList();
      args.add( "dob" );
      f.setFormula( yearFunction.render( args, null ) );
    }
  }
 
  public void testUpdateFalse() {
    getSessions().getStatistics().clear();
View Full Code Here

    SQLFunction lengthFunction = ( SQLFunction ) dialect.getFunctions().get( "length" );
    if ( lengthFunction != null ) {
      ArrayList args = new ArrayList();
      args.add( "bio" );
      f.setFormula( lengthFunction.render( args, null ) );
    }
  }

  public static Test suite() {
    return new FunctionalTestClassTestSuite( CompositeElementTest.class );
View Full Code Here

    }
    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 ) );
    }
  }

  // --- Inner classes (moved here from sql-gen.g) ---
View Full Code Here

    assertTranslation( "from Animal an where an.bodyWeight > abs(3/5)" );
    assertTranslation( "from Animal an where an.bodyWeight > abs(3+5)" );
    assertTranslation( "from Animal an where an.bodyWeight > abs(3*5)" );
    SQLFunction concat = getSessionFactoryImplementor().getSqlFunctionRegistry().findSQLFunction( "concat");
    List list = new ArrayList(); list.add("'fat'"); list.add("'skinny'");
    assertTranslation( "from Animal an where an.description = " + concat.render(list, getSessionFactoryImplementor()) );
  }

  public void testNotOrWhereClause() {
    assertTranslation( "from Simple s where 'foo'='bar' or not 'foo'='foo'" );
    assertTranslation( "from Simple s where 'foo'='bar' or not ('foo'='foo')" );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.