Search in sources :

Example 56 with StandardServiceRegistryBuilder

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

the class SchemaUpdateWithKeywordAutoQuotingEnabledTest method setUp.

@Before
public void setUp() throws IOException {
    final StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder();
    standardServiceRegistryBuilder.applySetting(org.hibernate.cfg.AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, "true");
    ssr = standardServiceRegistryBuilder.build();
    final MetadataSources metadataSources = new MetadataSources(ssr);
    metadataSources.addAnnotatedClass(Match.class);
    metadata = (MetadataImplementor) metadataSources.buildMetadata();
    metadata.validate();
    new SchemaExport().setHaltOnError(true).setFormat(false).createOnly(EnumSet.of(TargetType.DATABASE), metadata);
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataSources(org.hibernate.boot.MetadataSources) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Before(org.junit.Before)

Example 57 with StandardServiceRegistryBuilder

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

the class CrossSchemaForeignKeyGenerationTest method setUp.

@Before
public void setUp() throws IOException {
    output = File.createTempFile("update_script", ".sql");
    output.deleteOnExit();
    ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.HBM2DLL_CREATE_SCHEMAS, "true").build();
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Before(org.junit.Before)

Example 58 with StandardServiceRegistryBuilder

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

the class ManagedProviderConnectionHelper method createServiceRegistry.

private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
    Environment.verifyProperties(properties);
    ConfigurationHelper.resolvePlaceHolders(properties);
    return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings(properties).build();
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) StandardServiceRegistryImpl(org.hibernate.boot.registry.internal.StandardServiceRegistryImpl)

Example 59 with StandardServiceRegistryBuilder

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

the class SchemaUpdate method buildStandardServiceRegistry.

private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs parsedArgs) throws Exception {
    final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build();
    final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder(bsr);
    if (parsedArgs.cfgXmlFile != null) {
        ssrBuilder.configure(parsedArgs.cfgXmlFile);
    }
    if (parsedArgs.propertiesFile != null) {
        Properties props = new Properties();
        props.load(new FileInputStream(parsedArgs.propertiesFile));
        ssrBuilder.applySettings(props);
    }
    return ssrBuilder.build();
}
Also used : BootstrapServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Properties(java.util.Properties) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) FileInputStream(java.io.FileInputStream)

Example 60 with StandardServiceRegistryBuilder

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

the class SchemaUpdateTask method execute.

/**
	 * Execute the task
	 */
@Override
public void execute() throws BuildException {
    log("Running Hibernate Core SchemaUpdate.");
    log("This is an Ant task supporting only mapping files, if you want to use annotations see http://tools.hibernate.org.");
    try {
        final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder();
        configure(ssrBuilder);
        final StandardServiceRegistry ssr = ssrBuilder.build();
        final MetadataSources metadataSources = new MetadataSources(ssr);
        configure(metadataSources);
        final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
        configure(metadataBuilder, ssr);
        final MetadataImplementor metadata = (MetadataImplementor) metadataBuilder.build();
        new SchemaUpdate().setOutputFile(outputFile.getPath()).setDelimiter(delimiter).setHaltOnError(haltOnError).execute(TargetTypeHelper.parseLegacyCommandLineOptions(!quiet, !text, outputFile.getPath()), metadata);
    } catch (HibernateException e) {
        throw new BuildException("Schema text failed: " + e.getMessage(), e);
    } catch (FileNotFoundException e) {
        throw new BuildException("File not found: " + e.getMessage(), e);
    } catch (IOException e) {
        throw new BuildException("IOException : " + e.getMessage(), e);
    } catch (BuildException e) {
        throw e;
    } catch (Exception e) {
        throw new BuildException(e);
    }
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataBuilder(org.hibernate.boot.MetadataBuilder) HibernateException(org.hibernate.HibernateException) MetadataSources(org.hibernate.boot.MetadataSources) FileNotFoundException(java.io.FileNotFoundException) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) FileNotFoundException(java.io.FileNotFoundException) HibernateException(org.hibernate.HibernateException) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Aggregations

StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)167 MetadataSources (org.hibernate.boot.MetadataSources)106 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)94 Test (org.junit.Test)92 Metadata (org.hibernate.boot.Metadata)46 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)34 PersistentClass (org.hibernate.mapping.PersistentClass)27 Before (org.junit.Before)26 Properties (java.util.Properties)24 TestForIssue (org.hibernate.testing.TestForIssue)23 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)17 SessionFactory (org.hibernate.SessionFactory)15 BootstrapServiceRegistryBuilder (org.hibernate.boot.registry.BootstrapServiceRegistryBuilder)14 Property (org.hibernate.mapping.Property)14 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)14 File (java.io.File)13 BootstrapServiceRegistry (org.hibernate.boot.registry.BootstrapServiceRegistry)13 Map (java.util.Map)12 HashMap (java.util.HashMap)11 ServiceRegistry (org.hibernate.service.ServiceRegistry)11