use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.
the class LikeExpression method toSqlString.
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
final Dialect dialect = criteriaQuery.getFactory().getDialect();
final String[] columns = criteriaQuery.findColumns(propertyName, criteria);
if (columns.length != 1) {
throw new HibernateException("Like may only be used with single-column properties");
}
final String escape = escapeChar == null ? "" : " escape \'" + escapeChar + "\'";
final String column = columns[0];
if (ignoreCase) {
if (dialect.supportsCaseInsensitiveLike()) {
return column + " " + dialect.getCaseInsensitiveLike() + " ?" + escape;
} else {
return dialect.getLowercaseFunction() + '(' + column + ')' + " like ?" + escape;
}
} else {
return column + " like ?" + escape;
}
}
use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.
the class AbstractMultiTableBulkIdStrategyImpl method buildIdTableDropStatement.
protected String buildIdTableDropStatement(Table idTable, JdbcServices jdbcServices) {
final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
final Dialect dialect = jdbcEnvironment.getDialect();
return getIdTableSupport().getDropIdTableCommand() + " " + jdbcEnvironment.getQualifiedObjectNameFormatter().format(idTable.getQualifiedTableName(), dialect);
}
use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.
the class HibernateSchemaManagementTool method resolveJdbcContext.
public JdbcContext resolveJdbcContext(Map configurationValues) {
final JdbcContextBuilder jdbcContextBuilder = new JdbcContextBuilder(serviceRegistry);
// see if a specific connection has been provided
final Connection providedConnection = (Connection) configurationValues.get(HBM2DDL_CONNECTION);
if (providedConnection != null) {
jdbcContextBuilder.jdbcConnectionAccess = new JdbcConnectionAccessProvidedConnectionImpl(providedConnection);
}
// see if a specific Dialect override has been provided...
final String explicitDbName = (String) configurationValues.get(AvailableSettings.HBM2DDL_DB_NAME);
if (StringHelper.isNotEmpty(explicitDbName)) {
final String explicitDbMajor = (String) configurationValues.get(AvailableSettings.HBM2DDL_DB_MAJOR_VERSION);
final String explicitDbMinor = (String) configurationValues.get(AvailableSettings.HBM2DDL_DB_MINOR_VERSION);
final Dialect indicatedDialect = serviceRegistry.getService(DialectResolver.class).resolveDialect(new DialectResolutionInfo() {
@Override
public String getDatabaseName() {
return explicitDbName;
}
@Override
public int getDatabaseMajorVersion() {
return StringHelper.isEmpty(explicitDbMajor) ? NO_VERSION : Integer.parseInt(explicitDbMajor);
}
@Override
public int getDatabaseMinorVersion() {
return StringHelper.isEmpty(explicitDbMinor) ? NO_VERSION : Integer.parseInt(explicitDbMinor);
}
@Override
public String getDriverName() {
return null;
}
@Override
public int getDriverMajorVersion() {
return NO_VERSION;
}
@Override
public int getDriverMinorVersion() {
return NO_VERSION;
}
});
if (indicatedDialect == null) {
log.debugf("Unable to resolve indicated Dialect resolution info (%s, %s, %s)", explicitDbName, explicitDbMajor, explicitDbMinor);
} else {
jdbcContextBuilder.dialect = indicatedDialect;
}
}
return jdbcContextBuilder.buildJdbcContext();
}
use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.
the class SchemaDropperImpl method applyConstraintDropping.
private void applyConstraintDropping(Namespace namespace, Metadata metadata, Formatter formatter, ExecutionOptions options, GenerationTarget... targets) {
final Dialect dialect = metadata.getDatabase().getJdbcEnvironment().getDialect();
if (!dialect.dropConstraints()) {
return;
}
for (Table table : namespace.getTables()) {
if (!table.isPhysicalTable()) {
continue;
}
if (!schemaFilter.includeTable(table)) {
continue;
}
final Iterator fks = table.getForeignKeyIterator();
while (fks.hasNext()) {
final ForeignKey foreignKey = (ForeignKey) fks.next();
applySqlStrings(dialect.getForeignKeyExporter().getSqlDropStrings(foreignKey, metadata), formatter, options, targets);
}
}
}
use of org.hibernate.dialect.Dialect in project hibernate-orm by hibernate.
the class AbstractSequenceInformationExtractorTest method testSequenceGenerationExtractor.
@Test
public void testSequenceGenerationExtractor() {
final Dialect dialect = getDialect();
assertThat(dialect.getQuerySequencesString(), is(expectedQuerySequencesString()));
assertThat(dialect.getSequenceInformationExtractor(), instanceOf(expectedSequenceInformationExtractor()));
}
Aggregations