Package org.hibernate.dialect

Examples of org.hibernate.dialect.Dialect


                  }
                  else
                  {
                     connection = dataSource.getConnection();

                     Dialect d = DialectFactory.buildDialect(new Properties(), connection);
                     conf_.setProperty("hibernate.dialect", d.getClass().getName());
                  }
               }
               catch (NamingException e)
               {
                  log_.error(e.getMessage(), e);
               }
            }
            else
            {
               String url = conf_.getProperty("hibernate.connection.url");
               if (url != null)
               {
                  //detect dialect by url              
                  try
                  {
                     //load driver class
                     Class.forName(conf_.getProperty("hibernate.connection.driver_class")).newInstance();
                  }
                  catch (InstantiationException e)
                  {
                     log_.error(e.getMessage(), e);
                  }
                  catch (IllegalAccessException e)
                  {
                     log_.error(e.getMessage(), e);
                  }
                  catch (ClassNotFoundException e)
                  {
                     log_.error(e.getMessage(), e);
                  }

                  String dbUserName = conf_.getProperty("hibernate.connection.username");
                  String dbPassword = conf_.getProperty("hibernate.connection.password");

                  connection =
                     dbUserName != null ? DriverManager.getConnection(url, dbUserName, dbPassword) : DriverManager
                        .getConnection(url);

                  Dialect d = DialectFactory.buildDialect(new Properties(), connection);
                  conf_.setProperty("hibernate.dialect", d.getClass().getName());
               }
               else
               {
                  Exception e = new Exception("Any data source is not configured!");
                  log_.error(e.getMessage(), e);
View Full Code Here


        Environment.HBM2DDL_IMPORT_FILES,
        configuration.getProperties(),
        DEFAULT_IMPORT_FILE
    );

    final Dialect dialect = serviceRegistry.getService( JdbcServices.class ).getDialect();
    this.dropSQL = configuration.generateDropSchemaScript( dialect );
    this.createSQL = configuration.generateSchemaCreationScript( dialect );
  }
View Full Code Here

        AvailableSettings.HBM2DDL_IMPORT_FILES,
        serviceRegistry.getService( ConfigurationService.class ).getSettings(),
        DEFAULT_IMPORT_FILE
    );

    final Dialect dialect = jdbcServices.getDialect();
    this.dropSQL = metadata.getDatabase().generateDropSchemaScript( dialect );
    this.createSQL = metadata.getDatabase().generateSchemaCreationScript( dialect );
  }
View Full Code Here

   *
   * @deprecated properties may be specified via the Configuration object
   */
  @Deprecated
    public SchemaExport(Configuration configuration, Properties properties) throws HibernateException {
    final Dialect dialect = Dialect.getDialect( properties );

    Properties props = new Properties();
    props.putAll( dialect.getDefaultProperties() );
    props.putAll( properties );
    this.connectionHelper = new ManagedProviderConnectionHelper( props );

    this.sqlStatementLogger = new SqlStatementLogger( false, true );
    this.formatter = FormatStyle.DDL.getFormatter();
View Full Code Here

        Environment.HBM2DDL_IMPORT_FILES,
        configuration.getProperties(),
        DEFAULT_IMPORT_FILE
    );

    final Dialect dialect = Dialect.getDialect( configuration.getProperties() );
    this.dropSQL = configuration.generateDropSchemaScript( dialect );
    this.createSQL = configuration.generateSchemaCreationScript( dialect );
  }
View Full Code Here

          final boolean scroll,
          final SessionImplementor session) throws SQLException, HibernateException {

    queryParameters.processFilters( getSQLString(), session );
    String sql = queryParameters.getFilteredSQL();
    final Dialect dialect = getFactory().getDialect();
    final RowSelection selection = queryParameters.getRowSelection();
    boolean useLimit = useLimit( selection, dialect );
    boolean hasFirstRow = getFirstRow( selection ) > 0;
    boolean useOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset();
    boolean callable = queryParameters.isCallable();
   
    boolean useScrollableResultSetToSkip = hasFirstRow &&
        !useOffset &&
        getFactory().getSettings().isScrollableResultSetsEnabled();
    ScrollMode scrollMode = scroll ? queryParameters.getScrollMode() : ScrollMode.SCROLL_INSENSITIVE;

    if ( useLimit ) {
      sql = dialect.getLimitString(
          sql.trim(), //use of trim() here is ugly?
          useOffset ? getFirstRow(selection) : 0,
          getMaxOrLimit(selection, dialect)
        );
    }

    sql = preprocessSQL( sql, queryParameters, dialect );
   
    PreparedStatement st = null;
   
    if (callable) {
      st = session.getBatcher()
        .prepareCallableQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
    }
    else {
      st = session.getBatcher()
        .prepareQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
    }
       

    try {

      int col = 1;
      //TODO: can we limit stored procedures ?!
      if ( useLimit && dialect.bindLimitParametersFirst() ) {
        col += bindLimitParameters( st, col, selection );
      }
      if (callable) {
        col = dialect.registerResultSetOutParameter( (CallableStatement)st, col );
      }

      col += bindParameterValues( st, queryParameters, col, session );

      if ( useLimit && !dialect.bindLimitParametersFirst() ) {
        col += bindLimitParameters( st, col, selection );
      }

      if ( !useLimit ) {
        setMaxRows( st, selection );
View Full Code Here

   */
  private int bindLimitParameters(
      final PreparedStatement statement,
      final int index,
      final RowSelection selection) throws SQLException {
    Dialect dialect = getFactory().getDialect();
    if ( !dialect.supportsVariableLimit() ) {
      return 0;
    }
    if ( !hasMaxRows( selection ) ) {
      throw new AssertionFailure( "no max results set" );
    }
    int firstRow = getFirstRow( selection );
    int lastRow = getMaxOrLimit( selection, dialect );
    boolean hasFirstRow = firstRow > 0 && dialect.supportsLimitOffset();
    boolean reverse = dialect.bindLimitParametersInReverseOrder();
    if ( hasFirstRow ) {
      statement.setInt( index + ( reverse ? 1 : 0 ), firstRow );
    }
    statement.setInt( index + ( reverse || !hasFirstRow ? 0 : 1 ), lastRow );
    return hasFirstRow ? 2 : 1;
View Full Code Here

          final SessionImplementor session)
  throws SQLException, HibernateException {
 
    ResultSet rs = null;
    try {
      Dialect dialect = getFactory().getDialect();
      if (callable) {
        rs = session.getBatcher().getResultSet( (CallableStatement) st, dialect );
      }
      else {
        rs = session.getBatcher().getResultSet( st );
      }
      rs = wrapResultSetIfEnabled( rs , session );
     
      if ( !dialect.supportsLimitOffset() || !useLimit( selection, dialect ) ) {
        advance( rs, selection );
      }
     
      if ( autodiscovertypes ) {
        autoDiscoverTypes( rs );
View Full Code Here

      processedPositionalParameterTypes = getPositionalParameterTypes();
      processedSQL = sql;
    }
    else {
     
      Dialect dialect = session.getFactory().getDialect();
      String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
          .append( dialect.openQuote() )
          .append( dialect.closeQuote() )
          .toString();
      StringTokenizer tokens = new StringTokenizer( sql, symbols, true );
      StringBuffer result = new StringBuffer();
   
      List parameters = new ArrayList();
View Full Code Here

      return getCurrentTimestamp( session );
    }
  }

  private Timestamp getCurrentTimestamp(SessionImplementor session) {
    Dialect dialect = session.getFactory().getDialect();
    String timestampSelectString = dialect.getCurrentTimestampSelectString();
    if ( dialect.isCurrentTimestampSelectStringCallable() ) {
      return useCallableStatement( timestampSelectString, session );
    }
    else {
      return usePreparedStatement( timestampSelectString, session );
    }
View Full Code Here

TOP

Related Classes of org.hibernate.dialect.Dialect

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.