Caleb Cushing opened SPR-15864 and commented

We use Lucene with Hibernate Search. Currently I'm implementing a "Repository", in spirit of Spring Data JPA, but specific to doing the lucene queries. Turns out for lucene, we only need Specification like behavior (at least right now, maybe someday I'll write something that can execute string queries). Since No methods are required beyond the base ones to execute, we've decided that maybe it's best not to create a subclass just for that. The first of these has thus ended up like this.

@Configuration
public class LuceneRepositoryConfiguration {

    @Bean
    public LuceneSpecificationExecutor<ProviderTest> providerTestLuceneRepository() { // ProviderTest is one of our entities
        return new LuceneRepository<>( ProviderTest.class );
    }
}

However, since Hibernate Search does like run hibernate queries, it would be nice if this was wrapped in Springs Exception Wrapper, which happens automatically with @Repository for this reason I'm asking that @Repository be allowed on methods in @Configuration classes. (I'm honestly not sure why @Bean is needed, and why that couldn't have always been @Component


Affects: 4.3.10

Comment From: bclozel

Sorry it took us so long to respond here.

Given the lack of traction for this enhancement request, I'm going to decline it. Thanks for this proposal!