Search in sources :

Example 71 with Dialect

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

the class DummyMetadataBuildingContextTest method testInstance.

@Test
public void testInstance() {
    assertNotNull(DummyMetadataBuildingContext.INSTANCE);
    StandardServiceRegistry serviceRegistry = DummyMetadataBuildingContext.INSTANCE.getBootstrapContext().getServiceRegistry();
    JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    Dialect dialect = jdbcServices.getDialect();
    assertTrue(dialect instanceof MockDialect);
}
Also used : Dialect(org.hibernate.dialect.Dialect) JdbcServices(org.hibernate.engine.jdbc.spi.JdbcServices) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.jupiter.api.Test)

Example 72 with Dialect

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

the class DummyMetadataBuildingContextTest method testInstance.

@Test
public void testInstance() {
    assertNotNull(DummyMetadataBuildingContext.INSTANCE);
    StandardServiceRegistry serviceRegistry = DummyMetadataBuildingContext.INSTANCE.getBootstrapContext().getServiceRegistry();
    JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    Dialect dialect = jdbcServices.getDialect();
    assertTrue(dialect instanceof MockDialect);
}
Also used : Dialect(org.hibernate.dialect.Dialect) JdbcServices(org.hibernate.engine.jdbc.spi.JdbcServices) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.jupiter.api.Test)

Example 73 with Dialect

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

the class ColumnFacadeImpl method getSqlType.

@Override
public String getSqlType(IConfiguration configuration) {
    Column targetColumn = (Column) getTarget();
    Configuration configurationTarget = (Configuration) ((IFacade) configuration).getTarget();
    Properties properties = configurationTarget.getProperties();
    StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
    ssrb.applySettings(properties);
    StandardServiceRegistry ssr = ssrb.build();
    DialectFactory df = ssr.getService(DialectFactory.class);
    Dialect dialectTarget = df.buildDialect(properties, null);
    return targetColumn.getSqlType(dialectTarget, MetadataHelper.getMetadata(configurationTarget));
}
Also used : IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Column(org.hibernate.mapping.Column) Dialect(org.hibernate.dialect.Dialect) DialectFactory(org.hibernate.engine.jdbc.dialect.spi.DialectFactory) Properties(java.util.Properties) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Example 74 with Dialect

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

the class ServiceImpl method newDialect.

@Override
public String newDialect(Properties properties, Connection connection) {
    DialectFactoryImpl dialectFactory = new DialectFactoryImpl();
    dialectFactory.setClassLoaderService(new ClassLoaderServiceImpl());
    dialectFactory.setDialectResolver(new StandardDialectResolver());
    Dialect dialect = dialectFactory.buildDialect(properties, connection);
    return dialect != null ? dialect.toString() : null;
}
Also used : StandardDialectResolver(org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver) DialectFactoryImpl(org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl) MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) Dialect(org.hibernate.dialect.Dialect) ClassLoaderServiceImpl(org.hibernate.service.classloading.internal.ClassLoaderServiceImpl)

Example 75 with Dialect

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

the class ColumnFacadeImpl method getSqlType.

@Override
public String getSqlType(IConfiguration configuration) {
    Column targetColumn = (Column) getTarget();
    Configuration configurationTarget = (Configuration) ((IFacade) configuration).getTarget();
    Properties properties = configurationTarget.getProperties();
    StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
    ssrb.applySettings(properties);
    StandardServiceRegistry ssr = ssrb.build();
    DialectFactory df = ssr.getService(DialectFactory.class);
    Dialect dialectTarget = df.buildDialect(properties, null);
    return targetColumn.getSqlType(dialectTarget, MetadataHelper.getMetadata(configurationTarget));
}
Also used : IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Column(org.hibernate.mapping.Column) Dialect(org.hibernate.dialect.Dialect) DialectFactory(org.hibernate.engine.jdbc.dialect.spi.DialectFactory) Properties(java.util.Properties) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

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