@Override @SuppressWarnings("unchecked") public <B> ContainedBean<B> getBean( String name, Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) { if (!this.beanFactory.containsBean(name)) { return getBean(beanType, lifecycleOptions, fallbackProducer); } SpringContainedBean<?> bean; if (lifecycleOptions.canUseCachedReferences()) { bean = this.beanCache.get(name); if (bean == null) { bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); this.beanCache.put(name, bean); } } else { bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); } return (SpringContainedBean<B>) bean; }
/** * Set a Hibernate {@link org.hibernate.resource.beans.container.spi.BeanContainer} * for the given Spring {@link ConfigurableListableBeanFactory}. * <p>Note: Bean container integration requires Hibernate 5.3 or higher. * It enables autowiring of Hibernate attribute converters and entity listeners. * @since 5.1 * @see SpringBeanContainer * @see AvailableSettings#BEAN_CONTAINER */ public LocalSessionFactoryBuilder setBeanContainer(ConfigurableListableBeanFactory beanFactory) { getProperties().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory)); return this; }
@Override @SuppressWarnings("unchecked") public <B> ContainedBean<B> getBean( Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) { SpringContainedBean<?> bean; if (lifecycleOptions.canUseCachedReferences()) { bean = this.beanCache.get(beanType); if (bean == null) { bean = createBean(beanType, lifecycleOptions, fallbackProducer); this.beanCache.put(beanType, bean); } } else { bean = createBean(beanType, lifecycleOptions, fallbackProducer); } return (SpringContainedBean<B>) bean; }
@Override @SuppressWarnings("unchecked") public <B> ContainedBean<B> getBean( Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) { SpringContainedBean<?> bean; if (lifecycleOptions.canUseCachedReferences()) { bean = this.beanCache.get(beanType); if (bean == null) { bean = createBean(beanType, lifecycleOptions, fallbackProducer); this.beanCache.put(beanType, bean); } } else { bean = createBean(beanType, lifecycleOptions, fallbackProducer); } return (SpringContainedBean<B>) bean; }
@Override @SuppressWarnings("unchecked") public <B> ContainedBean<B> getBean( String name, Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) { if (!this.beanFactory.containsBean(name)) { return getBean(beanType, lifecycleOptions, fallbackProducer); } SpringContainedBean<?> bean; if (lifecycleOptions.canUseCachedReferences()) { bean = this.beanCache.get(name); if (bean == null) { bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); this.beanCache.put(name, bean); } } else { bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); } return (SpringContainedBean<B>) bean; }
@Override @SuppressWarnings("unchecked") public <B> ContainedBean<B> getBean( Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) { SpringContainedBean<?> bean; if (lifecycleOptions.canUseCachedReferences()) { bean = this.beanCache.get(beanType); if (bean == null) { bean = createBean(beanType, lifecycleOptions, fallbackProducer); this.beanCache.put(beanType, bean); } } else { bean = createBean(beanType, lifecycleOptions, fallbackProducer); } return (SpringContainedBean<B>) bean; }
/** * Set a Hibernate {@link org.hibernate.resource.beans.container.spi.BeanContainer} * for the given Spring {@link ConfigurableListableBeanFactory}. * <p>Note: Bean container integration requires Hibernate 5.3 or higher. * It enables autowiring of Hibernate attribute converters and entity listeners. * @since 5.1 * @see SpringBeanContainer * @see AvailableSettings#BEAN_CONTAINER */ public LocalSessionFactoryBuilder setBeanContainer(ConfigurableListableBeanFactory beanFactory) { getProperties().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory)); return this; }
@Override @SuppressWarnings("unchecked") public <B> ContainedBean<B> getBean( String name, Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) { if (!this.beanFactory.containsBean(name)) { return getBean(beanType, lifecycleOptions, fallbackProducer); } SpringContainedBean<?> bean; if (lifecycleOptions.canUseCachedReferences()) { bean = this.beanCache.get(name); if (bean == null) { bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); this.beanCache.put(name, bean); } } else { bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); } return (SpringContainedBean<B>) bean; }