Search in sources :

Example 46 with Dialect

use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.

the class SpatialRelateExpression method toSqlString.

@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    final SessionFactoryImplementor factory = criteriaQuery.getFactory();
    final String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, this.propertyName);
    final Dialect dialect = factory.getDialect();
    if (dialect instanceof SpatialDialect) {
        final SpatialDialect seDialect = (SpatialDialect) dialect;
        return seDialect.getSpatialRelateSQL(columns[0], spatialRelation);
    } else {
        throw new IllegalStateException("Dialect must be spatially enabled dialect");
    }
}
Also used : SpatialDialect(org.hibernate.spatial.SpatialDialect) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Dialect(org.hibernate.dialect.Dialect) SpatialDialect(org.hibernate.spatial.SpatialDialect)

Example 47 with Dialect

use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.

the class SpatialFilter method toSqlString.

@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    final SessionFactoryImplementor factory = criteriaQuery.getFactory();
    final String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, this.propertyName);
    final Dialect dialect = factory.getDialect();
    if (dialect instanceof SpatialDialect) {
        final SpatialDialect seDialect = (SpatialDialect) dialect;
        return seDialect.getSpatialFilterExpression(columns[0]);
    } else {
        throw new IllegalStateException("Dialect must be spatially enabled dialect");
    }
}
Also used : SpatialDialect(org.hibernate.spatial.SpatialDialect) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Dialect(org.hibernate.dialect.Dialect) SpatialDialect(org.hibernate.spatial.SpatialDialect)

Example 48 with Dialect

use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.

the class OracleSpatialProjection method toSqlString.

@Override
public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery) throws HibernateException {
    final SessionFactoryImplementor factory = criteriaQuery.getFactory();
    final String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, this.propertyName);
    final Dialect dialect = factory.getDialect();
    if (dialect instanceof SpatialDialect) {
        final SpatialDialect seDialect = (SpatialDialect) dialect;
        return new StringBuffer(seDialect.getSpatialAggregateSQL(columns[0], this.aggregate)).append(" y").append(position).append("_").toString();
    } else {
        throw new IllegalStateException("Dialect must be spatially enabled dialect");
    }
}
Also used : SpatialDialect(org.hibernate.spatial.SpatialDialect) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Dialect(org.hibernate.dialect.Dialect) SpatialDialect(org.hibernate.spatial.SpatialDialect)

Example 49 with Dialect

use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.

the class DbTimestampType method getCurrentTimestamp.

private Date getCurrentTimestamp(SharedSessionContractImplementor session) {
    Dialect dialect = session.getJdbcServices().getJdbcEnvironment().getDialect();
    String timestampSelectString = dialect.getCurrentTimestampSelectString();
    if (dialect.isCurrentTimestampSelectStringCallable()) {
        return useCallableStatement(timestampSelectString, session);
    }
    return usePreparedStatement(timestampSelectString, session);
}
Also used : Dialect(org.hibernate.dialect.Dialect)

Example 50 with Dialect

use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.

the class TableStructure method registerExportables.

@Override
public void registerExportables(Database database) {
    final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment();
    final Dialect dialect = jdbcEnvironment.getDialect();
    final Namespace namespace = database.locateNamespace(logicalQualifiedTableName.getCatalogName(), logicalQualifiedTableName.getSchemaName());
    Table table = namespace.locateTable(logicalQualifiedTableName.getObjectName());
    if (table == null) {
        table = namespace.createTable(logicalQualifiedTableName.getObjectName(), false);
    }
    this.tableNameText = jdbcEnvironment.getQualifiedObjectNameFormatter().format(table.getQualifiedTableName(), dialect);
    this.valueColumnNameText = logicalValueColumnNameIdentifier.render(dialect);
    this.selectQuery = "select " + valueColumnNameText + " as id_val" + " from " + dialect.appendLockHint(LockMode.PESSIMISTIC_WRITE, tableNameText) + dialect.getForUpdateString();
    this.updateQuery = "update " + tableNameText + " set " + valueColumnNameText + "= ?" + " where " + valueColumnNameText + "=?";
    ExportableColumn valueColumn = new ExportableColumn(database, table, valueColumnNameText, LongType.INSTANCE);
    table.addColumn(valueColumn);
    table.addInitCommand(new InitCommand("insert into " + tableNameText + " values ( " + initialValue + " )"));
}
Also used : Table(org.hibernate.mapping.Table) InitCommand(org.hibernate.boot.model.relational.InitCommand) Dialect(org.hibernate.dialect.Dialect) ExportableColumn(org.hibernate.id.ExportableColumn) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) Namespace(org.hibernate.boot.model.relational.Namespace)

Aggregations

Dialect (org.hibernate.dialect.Dialect)80 DialectFactory (org.hibernate.engine.jdbc.dialect.spi.DialectFactory)19 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)18 Column (org.hibernate.mapping.Column)14 SQLException (java.sql.SQLException)13 DialectResolutionInfo (org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo)12 JdbcServices (org.hibernate.engine.jdbc.spi.JdbcServices)12 Configuration (org.hibernate.cfg.Configuration)11 ServiceRegistry (org.hibernate.service.ServiceRegistry)11 Properties (java.util.Properties)10 HibernateException (org.hibernate.HibernateException)10 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)10 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)9 DatabaseMetaDataDialectResolutionInfoAdapter (org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter)9 DialectResolutionInfoSource (org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource)9 HibernateException (org.jboss.tools.hibernate.runtime.spi.HibernateException)9 MetaDataDialect (org.hibernate.cfg.reveng.dialect.MetaDataDialect)8 Test (org.junit.jupiter.api.Test)8 JdbcEnvironment (org.hibernate.engine.jdbc.env.spi.JdbcEnvironment)7 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)6