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();
}
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);
}
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();
}
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);
}
}
}
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;
}
Aggregations