Search in sources :

Example 1 with ExtractedDatabaseMetaData

use of org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData in project hibernate-orm by hibernate.

the class ProcedureCallImpl method prepareForNamedParameters.

private void prepareForNamedParameters() {
    if (parameterStrategy == ParameterStrategy.POSITIONAL) {
        throw new QueryException("Cannot mix named and positional parameters");
    }
    if (parameterStrategy == ParameterStrategy.UNKNOWN) {
        // protect to only do this check once
        final ExtractedDatabaseMetaData databaseMetaData = getSession().getJdbcCoordinator().getJdbcSessionOwner().getJdbcSessionContext().getServiceRegistry().getService(JdbcEnvironment.class).getExtractedDatabaseMetaData();
        if (!databaseMetaData.supportsNamedParameters()) {
            LOG.unsupportedNamedParameters();
        }
        parameterStrategy = ParameterStrategy.NAMED;
    }
}
Also used : QueryException(org.hibernate.QueryException) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) ExtractedDatabaseMetaData(org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData)

Example 2 with ExtractedDatabaseMetaData

use of org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData in project hibernate-orm by hibernate.

the class NoDatabaseMetaDataTest method testNoJdbcMetadataDefaultDialect.

@Test
@TestForIssue(jiraKey = "HHH-10515")
public void testNoJdbcMetadataDefaultDialect() {
    final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySetting("hibernate.temp.use_jdbc_metadata_defaults", "false").build();
    JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class);
    ExtractedDatabaseMetaData extractedDatabaseMetaData = jdbcEnvironment.getExtractedDatabaseMetaData();
    assertNull(extractedDatabaseMetaData.getConnectionCatalogName());
    assertNull(extractedDatabaseMetaData.getConnectionSchemaName());
    assertTrue(extractedDatabaseMetaData.getTypeInfoSet().isEmpty());
    assertTrue(extractedDatabaseMetaData.getExtraKeywords().isEmpty());
    assertFalse(extractedDatabaseMetaData.supportsNamedParameters());
    assertFalse(extractedDatabaseMetaData.supportsRefCursors());
    assertFalse(extractedDatabaseMetaData.supportsScrollableResults());
    assertFalse(extractedDatabaseMetaData.supportsGetGeneratedKeys());
    assertFalse(extractedDatabaseMetaData.supportsBatchUpdates());
    assertFalse(extractedDatabaseMetaData.supportsDataDefinitionInTransaction());
    assertFalse(extractedDatabaseMetaData.doesDataDefinitionCauseTransactionCommit());
    assertNull(extractedDatabaseMetaData.getSqlStateType());
    assertFalse(extractedDatabaseMetaData.doesLobLocatorUpdateCopy());
    StandardServiceRegistryBuilder.destroy(serviceRegistry);
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) ExtractedDatabaseMetaData(org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 3 with ExtractedDatabaseMetaData

use of org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData in project hibernate-orm by hibernate.

the class NoDatabaseMetaDataTest method testNoJdbcMetadataDialectOverride.

@Test
@TestForIssue(jiraKey = "HHH-10515")
public void testNoJdbcMetadataDialectOverride() {
    final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySetting("hibernate.temp.use_jdbc_metadata_defaults", "false").applySetting(AvailableSettings.DIALECT, TestDialect.class.getName()).build();
    JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class);
    ExtractedDatabaseMetaData extractedDatabaseMetaData = jdbcEnvironment.getExtractedDatabaseMetaData();
    assertNull(extractedDatabaseMetaData.getConnectionCatalogName());
    assertNull(extractedDatabaseMetaData.getConnectionSchemaName());
    assertTrue(extractedDatabaseMetaData.getTypeInfoSet().isEmpty());
    assertTrue(extractedDatabaseMetaData.getExtraKeywords().isEmpty());
    assertTrue(extractedDatabaseMetaData.supportsNamedParameters());
    assertFalse(extractedDatabaseMetaData.supportsRefCursors());
    assertFalse(extractedDatabaseMetaData.supportsScrollableResults());
    assertFalse(extractedDatabaseMetaData.supportsGetGeneratedKeys());
    assertFalse(extractedDatabaseMetaData.supportsBatchUpdates());
    assertFalse(extractedDatabaseMetaData.supportsDataDefinitionInTransaction());
    assertFalse(extractedDatabaseMetaData.doesDataDefinitionCauseTransactionCommit());
    assertNull(extractedDatabaseMetaData.getSqlStateType());
    assertFalse(extractedDatabaseMetaData.doesLobLocatorUpdateCopy());
    StandardServiceRegistryBuilder.destroy(serviceRegistry);
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) ExtractedDatabaseMetaData(org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

ExtractedDatabaseMetaData (org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData)3 JdbcEnvironment (org.hibernate.engine.jdbc.env.spi.JdbcEnvironment)3 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)2 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)2 TestForIssue (org.hibernate.testing.TestForIssue)2 Test (org.junit.Test)2 QueryException (org.hibernate.QueryException)1