Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.orm.hibernate5;
import java.util.Map;
import java.util.function.Consumer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;
/**
* Spring's implementation of Hibernate 5.3's {@link BeanContainer} SPI,
* delegating to a Spring {@link ConfigurableListableBeanFactory}.
*
*
Auto-configured by {@link LocalSessionFactoryBean#setBeanFactory},
* programmatically supported via {@link LocalSessionFactoryBuilder#setBeanContainer},
* and manually configurable through a "hibernate.resource.beans.container" entry
* in JPA properties, e.g.:
*
*
* LocalContainerEntityManagerFactoryBean emfb = ...
* emfb.getJpaPropertyMap().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory));
*
*
* Please note that Spring's {@link LocalSessionFactoryBean} is an immediate alternative
* to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for common
* JPA purposes: In particular with Hibernate 5.3, the Hibernate {@code SessionFactory}
* will natively expose the JPA {@code EntityManagerFactory} interface as well, and
* Hibernate {@code BeanContainer} integration will be registered out of the box.
*
* @author Juergen Hoeller
* @since 5.1
* @see LocalSessionFactoryBean#setBeanFactory
* @see LocalSessionFactoryBuilder#setBeanContainer
* @see org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#setJpaPropertyMap
* @see org.hibernate.cfg.AvailableSettings#BEAN_CONTAINER
*/
public final class SpringBeanContainer implements BeanContainer {
private static final Log logger = LogFactory.getLog(SpringBeanContainer.class);
private final ConfigurableListableBeanFactory beanFactory;
private final Map