use of org.hibernate.boot.model.relational.AuxiliaryDatabaseObject in project hibernate-orm by hibernate.
the class Configuration method buildSessionFactory.
/**
* Create a {@link SessionFactory} using the properties and mappings in this configuration. The
* SessionFactory will be immutable, so changes made to this Configuration afterQuery building the
* SessionFactory will not affect it.
*
* @param serviceRegistry The registry of services to be used in creating this session factory.
*
* @return The built {@link SessionFactory}
*
* @throws HibernateException usually indicates an invalid configuration or invalid mapping information
*/
public SessionFactory buildSessionFactory(ServiceRegistry serviceRegistry) throws HibernateException {
log.debug("Building session factory using provided StandardServiceRegistry");
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder((StandardServiceRegistry) serviceRegistry);
if (implicitNamingStrategy != null) {
metadataBuilder.applyImplicitNamingStrategy(implicitNamingStrategy);
}
if (physicalNamingStrategy != null) {
metadataBuilder.applyPhysicalNamingStrategy(physicalNamingStrategy);
}
if (sharedCacheMode != null) {
metadataBuilder.applySharedCacheMode(sharedCacheMode);
}
if (!typeContributorRegistrations.isEmpty()) {
for (TypeContributor typeContributor : typeContributorRegistrations) {
metadataBuilder.applyTypes(typeContributor);
}
}
if (!basicTypes.isEmpty()) {
for (BasicType basicType : basicTypes) {
metadataBuilder.applyBasicType(basicType);
}
}
if (sqlFunctions != null) {
for (Map.Entry<String, SQLFunction> entry : sqlFunctions.entrySet()) {
metadataBuilder.applySqlFunction(entry.getKey(), entry.getValue());
}
}
if (auxiliaryDatabaseObjectList != null) {
for (AuxiliaryDatabaseObject auxiliaryDatabaseObject : auxiliaryDatabaseObjectList) {
metadataBuilder.applyAuxiliaryDatabaseObject(auxiliaryDatabaseObject);
}
}
if (attributeConverterDefinitionsByClass != null) {
for (AttributeConverterDefinition attributeConverterDefinition : attributeConverterDefinitionsByClass.values()) {
metadataBuilder.applyAttributeConverter(attributeConverterDefinition);
}
}
final Metadata metadata = metadataBuilder.build();
final SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
if (interceptor != null && interceptor != EmptyInterceptor.INSTANCE) {
sessionFactoryBuilder.applyInterceptor(interceptor);
}
if (getSessionFactoryObserver() != null) {
sessionFactoryBuilder.addSessionFactoryObservers(getSessionFactoryObserver());
}
if (getEntityNotFoundDelegate() != null) {
sessionFactoryBuilder.applyEntityNotFoundDelegate(getEntityNotFoundDelegate());
}
if (getEntityTuplizerFactory() != null) {
sessionFactoryBuilder.applyEntityTuplizerFactory(getEntityTuplizerFactory());
}
if (getCurrentTenantIdentifierResolver() != null) {
sessionFactoryBuilder.applyCurrentTenantIdentifierResolver(getCurrentTenantIdentifierResolver());
}
return sessionFactoryBuilder.build();
}
Aggregations