문제

I use Hibernate Search programmatic api and I have configurable boosting for each entity. Configuration can be read through service which I need to access in mapping factory. Is it possible to get this bean somehow inside SearchMappingFactory? The problem is that spring context is not fully created at the moment the search mapping needs beans from it.

 public class SearchMappingFactory{

   @Factory
   public SearchMapping getSearchMapping() {
       SearchMapping searchMapping = new SearchMapping();

       // here I need to read configuration using configurationService
       // ... define mapping ...

       return searchMapping;
   }
 }

Then I set this mapping in sessionFactory this way

 hibernateProperties.put("hibernate.search.model_mapping", SearchMappingFactory.class.getCanonicalName());

I could pass instance of SearchMappingFactory with autowired bean inside but SearchMappingBuilder.getProgrammaticMappingClass does not allow that...

도움이 되었습니까?

해결책

I found the solution, I made SearchMappingFactory a bean with autowired dependencies and passed searchMapping directly there:

 hibernateProperties.put("hibernate.search.model_mapping", searchMappingFactory.getSearchMapping());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top