Search in sources :

Example 86 with StandardServiceRegistryBuilder

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

the class BaseCoreFunctionalTestCase method buildServiceRegistry.

protected StandardServiceRegistryImpl buildServiceRegistry(BootstrapServiceRegistry bootRegistry, Configuration configuration) {
    Properties properties = new Properties();
    properties.putAll(configuration.getProperties());
    Environment.verifyProperties(properties);
    ConfigurationHelper.resolvePlaceHolders(properties);
    StandardServiceRegistryBuilder cfgRegistryBuilder = configuration.getStandardServiceRegistryBuilder();
    StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(bootRegistry, cfgRegistryBuilder.getAggregatedCfgXml()).applySettings(properties);
    prepareBasicRegistryBuilder(registryBuilder);
    return (StandardServiceRegistryImpl) registryBuilder.build();
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) StandardServiceRegistryImpl(org.hibernate.boot.registry.internal.StandardServiceRegistryImpl)

Example 87 with StandardServiceRegistryBuilder

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

the class BaseNonConfigCoreFunctionalTestCase method buildResources.

protected void buildResources() {
    final StandardServiceRegistryBuilder ssrb = constructStandardServiceRegistryBuilder();
    serviceRegistry = ssrb.build();
    afterStandardServiceRegistryBuilt(serviceRegistry);
    final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
    applyMetadataSources(metadataSources);
    afterMetadataSourcesApplied(metadataSources);
    final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
    initialize(metadataBuilder);
    configureMetadataBuilder(metadataBuilder);
    metadata = (MetadataImplementor) metadataBuilder.build();
    applyCacheSettings(metadata);
    afterMetadataBuilt(metadata);
    final SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder();
    initialize(sfb, metadata);
    configureSessionFactoryBuilder(sfb);
    sessionFactory = (SessionFactoryImplementor) sfb.build();
    afterSessionFactoryBuilt(sessionFactory);
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataBuilder(org.hibernate.boot.MetadataBuilder) SessionFactoryBuilder(org.hibernate.boot.SessionFactoryBuilder) MetadataSources(org.hibernate.boot.MetadataSources)

Example 88 with StandardServiceRegistryBuilder

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

the class ProxoolTransactionIsolationConfigTest method setUp.

@Before
public void setUp() {
    String poolName = "pool-one";
    properties = new Properties();
    properties.put(AvailableSettings.PROXOOL_POOL_ALIAS, poolName);
    properties.put(AvailableSettings.PROXOOL_PROPERTIES, poolName + ".properties");
    ssr = new StandardServiceRegistryBuilder().applySettings(properties).build();
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Properties(java.util.Properties) Before(org.junit.Before)

Example 89 with StandardServiceRegistryBuilder

use of org.hibernate.boot.registry.StandardServiceRegistryBuilder in project ice by JBEI.

the class HibernateUtil method initialize.

private static synchronized void initialize(Type type) {
    if (sessionFactory == null) {
        Logger.info("Initializing session factory for type " + type.name());
        final Configuration configuration = new Configuration();
        try {
            if (type == Type.MOCK) {
                configuration.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
                configuration.setProperty("hibernate.connection.driver_class", "org.h2.Driver");
                configuration.setProperty("hibernate.connection.username", "sa");
                configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
                configuration.setProperty("hibernate.current_session_context_class", "org.hibernate.context.internal.ThreadLocalSessionContext");
                configuration.setProperty("hibernate.hbm2ddl.auto", "update");
                configuration.setProperty("hibernate.search.default.directory_provider", "org.hibernate.search.store.impl.RAMDirectoryProvider");
            } else {
                configuration.configure();
            }
            ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Entry.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Plasmid.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Strain.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Part.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.ArabidopsisSeed.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Link.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.SelectionMarker.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Sequence.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Feature.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.SequenceFeature.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.SequenceFeatureAttribute.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Comment.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Account.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Attachment.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Sample.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.AccountPreferences.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Group.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.TraceSequence.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.TraceSequenceAlignment.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Configuration.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Storage.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Folder.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Parameter.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.AnnotationLocation.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.BulkUpload.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Permission.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Message.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Preference.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.RemotePartner.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Request.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Audit.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Experiment.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.ShotgunSequence.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.Configuration.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.ApiKey.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.RemoteClientModel.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.RemoteShareModel.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.RemoteAccessModel.class);
            configuration.addAnnotatedClass(org.jbei.ice.storage.model.ManuscriptModel.class);
            configuration.addAnnotatedClass(FeatureCurationModel.class);
            sessionFactory = configuration.buildSessionFactory(serviceRegistry);
        } catch (Throwable e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}
Also used : Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) ServiceRegistry(org.hibernate.service.ServiceRegistry)

Example 90 with StandardServiceRegistryBuilder

use of org.hibernate.boot.registry.StandardServiceRegistryBuilder in project zhcet-web by zhcet-amu.

the class Hibernate5DDLExporter method schemaExport.

private Hibernate5DDLExporter schemaExport(String fileName, String targetDirectory) throws Exception {
    if (entityPackages == null && entityPackages.length == 0) {
        System.out.println("Not packages selected");
        System.exit(0);
    }
    File exportFile = createExportFileAndMakeDirectory(fileName, targetDirectory);
    PhysicalNamingStrategy physicalNamingStrategy;
    ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DIALECT, dialect).applySetting(AvailableSettings.PHYSICAL_NAMING_STRATEGY, "org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy").build();
    MetadataImplementor metadata = (MetadataImplementor) mapAnnotatedClasses(serviceRegistry).buildMetadata();
    SchemaExport schemaExport = new SchemaExport();
    schemaExport.setOutputFile(exportFile.getAbsolutePath());
    schemaExport.setDelimiter(";");
    schemaExport.setFormat(true);
    schemaExport.execute(EnumSet.of(TargetType.SCRIPT), SchemaExport.Action.CREATE, metadata, serviceRegistry);
    ((StandardServiceRegistryImpl) serviceRegistry).destroy();
    System.out.println(exportFile.getAbsolutePath());
    return this;
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) ServiceRegistry(org.hibernate.service.ServiceRegistry) File(java.io.File) StandardServiceRegistryImpl(org.hibernate.boot.registry.internal.StandardServiceRegistryImpl) PhysicalNamingStrategy(org.hibernate.boot.model.naming.PhysicalNamingStrategy) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport)

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