content: package com.bookstore.config;
  
  import com.blazebit.persistence.Criteria;
  import com.blazebit.persistence.CriteriaBuilderFactory;
  import com.blazebit.persistence.integration.view.spring.EnableEntityViews;
  import com.blazebit.persistence.spi.CriteriaBuilderConfiguration;
  import com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactoryBean;
  import com.blazebit.persistence.view.EntityViewManager;
  import com.blazebit.persistence.view.spi.EntityViewConfiguration;
  import org.springframework.beans.factory.config.ConfigurableBeanFactory;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.Lazy;
  import org.springframework.context.annotation.Scope;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
  
  @Configuration
  @EnableEntityViews("com.bookstore")
  @EnableJpaRepositories(
          basePackages = "com.bookstore",
          repositoryFactoryBeanClass = BlazePersistenceRepositoryFactoryBean.class)
  public class BlazeConfiguration {
  
      private final LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean;
  
      public BlazeConfiguration(LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean) {
          this.localContainerEntityManagerFactoryBean = localContainerEntityManagerFactoryBean;
      }
  
      @Bean
      @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
      @Lazy(false)
      public CriteriaBuilderFactory createCriteriaBuilderFactory() {
          CriteriaBuilderConfiguration config = Criteria.getDefault();
          return config.createCriteriaBuilderFactory(localContainerEntityManagerFactoryBean.getObject());
      }
  
      @Bean
      @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
      @Lazy(false)
      public EntityViewManager createEntityViewManager(CriteriaBuilderFactory cbf,
              EntityViewConfiguration entityViewConfiguration) {
          return entityViewConfiguration.createEntityViewManager(cbf);
      }
  }
  