Search in sources :

Example 46 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.

the class SchemaUpdate method main.

public static void main(String[] args) {
    try {
        final CommandLineArgs parsedArgs = CommandLineArgs.parseCommandLineArgs(args);
        final StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry(parsedArgs);
        try {
            final MetadataImplementor metadata = buildMetadata(parsedArgs, serviceRegistry);
            new SchemaUpdate().setOutputFile(parsedArgs.outputFile).setDelimiter(parsedArgs.delimiter).execute(parsedArgs.targetTypes, metadata, serviceRegistry);
        } finally {
            StandardServiceRegistryBuilder.destroy(serviceRegistry);
        }
    } catch (Exception e) {
        LOG.unableToRunSchemaUpdate(e);
        e.printStackTrace();
    }
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Example 47 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.

the class SchemaValidator method main.

public static void main(String[] args) {
    try {
        final CommandLineArgs parsedArgs = CommandLineArgs.parseCommandLineArgs(args);
        final StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry(parsedArgs);
        try {
            final MetadataImplementor metadata = buildMetadata(parsedArgs, serviceRegistry);
            new SchemaValidator().validate(metadata, serviceRegistry);
        } finally {
            StandardServiceRegistryBuilder.destroy(serviceRegistry);
        }
    } catch (Exception e) {
        LOG.unableToRunSchemaUpdate(e);
        e.printStackTrace();
    }
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Example 48 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry 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, configurationTarget.buildMapping());
}
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 49 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry 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 50 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry 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

StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)169 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)152 Test (org.junit.Test)121 MetadataSources (org.hibernate.boot.MetadataSources)118 Metadata (org.hibernate.boot.Metadata)56 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)39 PersistentClass (org.hibernate.mapping.PersistentClass)39 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)25 TestForIssue (org.hibernate.testing.TestForIssue)24 BootstrapServiceRegistryBuilder (org.hibernate.boot.registry.BootstrapServiceRegistryBuilder)23 Properties (java.util.Properties)20 BootstrapServiceRegistry (org.hibernate.boot.registry.BootstrapServiceRegistry)20 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)15 SessionFactory (org.hibernate.SessionFactory)14 Column (org.hibernate.mapping.Column)14 Property (org.hibernate.mapping.Property)14 Session (org.hibernate.Session)13 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)12 IdentifierGenerator (org.hibernate.id.IdentifierGenerator)11 RootClass (org.hibernate.mapping.RootClass)11