Package org.hibernate.dialect

Examples of org.hibernate.dialect.Dialect


          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


      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

  }

  public String toSqlString(
      Criteria criteria,
      CriteriaQuery criteriaQuery) throws HibernateException {
    Dialect dialect = criteriaQuery.getFactory().getDialect();
    String[] columns = criteriaQuery.getColumnsUsingProjection( criteria, propertyName );
    if ( columns.length != 1 ) {
      throw new HibernateException( "Like may only be used with single-column properties" );
    }
    String lhs = ignoreCase
        ? dialect.getLowercaseFunction() + '(' + columns[0] + ')'
              : columns[0];
    return lhs + " like ?" + ( escapeChar == null ? "" : " escape \'" + escapeChar + "\'" );

  }
View Full Code Here

        && ( ! hasDynamicFilterParam( sqlFragment ) )
        && ( ! ( hasCollectionFilterParam( sqlFragment ) ) ) ) {
      return;
    }

    Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
    String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
        .append( dialect.openQuote() )
        .append( dialect.closeQuote() )
        .toString();
    StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
    StringBuffer result = new StringBuffer();

    while ( tokens.hasMoreTokens() ) {
View Full Code Here

  }

  private String resolveToLiteralString(Type type) {
    try {
      LiteralType literalType = ( LiteralType ) type;
      Dialect dialect = factory.getDialect();
      return literalType.objectToSQLString( constantValue, dialect );
    }
    catch ( Throwable t ) {
      throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + constantExpression, t );
    }
View Full Code Here

        final AuditEntitiesConfiguration audEntitiesCfg = auditCfg.getAuditEntCfg();
        final String auditedEntityName = audEntitiesCfg.getAuditEntityName( entityName );
    final String revisionInfoEntityName = auditCfg.getAuditEntCfg().getRevisionInfoEntityName();
    final SessionImplementor sessionImplementor = (SessionImplementor) session;
    final Dialect dialect = sessionImplementor.getFactory().getDialect();

        // Save the audit data
        session.save(auditedEntityName, data);
        sessionCacheCleaner.scheduleAuditDataRemoval(session, data);
View Full Code Here

  public DeleteExecutor(HqlSqlWalker walker, Queryable persister) {
    super( walker, persister );
   
    final SessionFactoryImplementor factory = walker.getSessionFactoryHelper().getFactory();
    final Dialect dialect = factory.getDialect();
   
    try {
      final DeleteStatement deleteStatement = (DeleteStatement) walker.getAST();
     
      final String idSubselectWhere;
      if ( deleteStatement.hasWhereClause() ) {
        final AST whereClause = deleteStatement.getWhereClause();
        final SqlGenerator gen = new SqlGenerator( factory );
        gen.whereClause( whereClause );
        parameterSpecifications = gen.getCollectedParameters();
        idSubselectWhere = gen.getSQL().length() > 7 ? gen.getSQL() : "";
      }
      else {
        parameterSpecifications = new ArrayList<ParameterSpecification>();
        idSubselectWhere = "";
      }
     
      // If many-to-many, delete the FK row in the collection table.
      for ( Type type : persister.getPropertyTypes() ) {
        if ( type.isCollectionType() ) {
          final CollectionType cType = (CollectionType) type;
          final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
              .getCollectionPersister( cType.getRole() );
          if ( cPersister.isManyToMany() ) {
            if ( persister.getIdentifierColumnNames().length > 1
                && !dialect.supportsTuplesInSubqueries() ) {
              LOG.warn(
                  "This dialect is unable to cascade the delete into the many-to-many join table" +
                  " when the entity has multiple primary keys.  Either properly setup cascading on" +
                  " the constraints or manually clear the associations prior to deleting the entities."
              );
View Full Code Here

        typeResolver.registerTypeOverride( type, keys );
      }
    };

    // add Dialect contributed types
    final Dialect dialect = serviceRegistry.getService( JdbcServices.class ).getDialect();
    dialect.contributeTypes( typeContributions, serviceRegistry );

    // add TypeContributor contributed types.
    ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
    for ( TypeContributor contributor : classLoaderService.loadJavaServices( TypeContributor.class ) ) {
      contributor.contribute( typeContributions, serviceRegistry );
View Full Code Here

          hibernateConfiguration,
          serviceRegistry
      );

      try {
        final Dialect dialect = determineDialect( jdbcConnectionContext, hibernateConfiguration, serviceRegistry );


        // determine sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        final List<GenerationSource> createSourceList = databaseAction.includesCreate() || scriptsAction.includesCreate()
View Full Code Here

    return new int[ getPropertySpan() ];
  }

  protected String generateSubquery(PersistentClass model, Mapping mapping) {

    Dialect dialect = getFactory().getDialect();
    Settings settings = getFactory().getSettings();
   
    if ( !model.hasSubclasses() ) {
      return model.getTable().getQualifiedName(
          dialect,
          settings.getDefaultCatalogName(),
          settings.getDefaultSchemaName()
        );
    }

    HashSet columns = new LinkedHashSet();
    Iterator titer = model.getSubclassTableClosureIterator();
    while ( titer.hasNext() ) {
      Table table = (Table) titer.next();
      if ( !table.isAbstractUnionTable() ) {
        Iterator citer = table.getColumnIterator();
        while ( citer.hasNext() ) columns.add( citer.next() );
      }
    }

    StringBuilder buf = new StringBuilder()
      .append("( ");

    Iterator siter = new JoinedIterator(
      new SingletonIterator(model),
      model.getSubclassIterator()
    );

    while ( siter.hasNext() ) {
      PersistentClass clazz = (PersistentClass) siter.next();
      Table table = clazz.getTable();
      if ( !table.isAbstractUnionTable() ) {
        //TODO: move to .sql package!!
        buf.append("select ");
        Iterator citer = columns.iterator();
        while ( citer.hasNext() ) {
          Column col = (Column) citer.next();
          if ( !table.containsColumn(col) ) {
            int sqlType = col.getSqlTypeCode(mapping);
            buf.append( dialect.getSelectClauseNullString(sqlType) )
              .append(" as ");
          }
          buf.append( col.getName() );
          buf.append(", ");
        }
        buf.append( clazz.getSubclassId() )
          .append(" as clazz_");
        buf.append(" from ")
          .append( table.getQualifiedName(
              dialect,
              settings.getDefaultCatalogName(),
              settings.getDefaultSchemaName()
          ) );
        buf.append(" union ");
        if ( dialect.supportsUnionAll() ) {
          buf.append("all ");
        }
      }
    }
   
    if ( buf.length() > 2 ) {
      //chop the last union (all)
      buf.setLength( buf.length() - ( dialect.supportsUnionAll() ? 11 : 7 ) );
    }

    return buf.append(" )").toString();
  }
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.