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 + " )"));
}
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");
}
}
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");
}
}
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");
}
}
use of org.hibernate.dialect.Dialect in project uPortal by Jasig.
the class DbTestImpl method printDbInfo.
@Override
public void printDbInfo() {
boolean fail = false;
logger.info("JDBC DataSources");
for (final Entry<String, JdbcOperations> jdbcEntry : this.jdbcOperations.entrySet()) {
final String jdbcName = jdbcEntry.getKey();
try {
logger.info("\t" + jdbcName);
final JdbcOperations jdbcOps = jdbcEntry.getValue();
jdbcOps.execute(new ConnectionCallback<Object>() {
@Override
public Object doInConnection(Connection con) throws SQLException, DataAccessException {
printInfo(con);
return null;
}
});
} catch (Exception e) {
logger.error("\t" + jdbcName + ": parse info", e);
fail = true;
}
logger.info("");
}
logger.info("Hibernate Dialects");
for (final Entry<String, HibernateConfiguration> configEntry : this.hibernateConfigurations.entrySet()) {
final String persistenceUnit = configEntry.getKey();
try {
final HibernateConfiguration hibernateConfiguration = configEntry.getValue();
final SessionFactoryImplementor sessionFactory = hibernateConfiguration.getSessionFactory();
final Dialect dialect = sessionFactory.getDialect();
logger.info("\t" + persistenceUnit + ": " + dialect);
} catch (Exception e) {
logger.error("\t" + persistenceUnit + ": Failed to resolve Dialect", e);
fail = true;
}
logger.info("");
}
if (fail) {
throw new RuntimeException("One or more of the portal data sources is not configured correctly or the target database is not available.");
}
}
Aggregations