Domanda

Ho davvero problemi con l'inizializzazione del repository JPA utilizzando il repository di SOLR dei dati a molla.Sto cercando di aggiungere un repository personalizzato per costruire una query dinamica.Ho letto alcuni overflow stack e altri collegamenti che suggeriscono che il problema è che non sto seguendo la giusta convenzione di denominazione per il mio repository personalizzato.Rif: https://jira.spring.io/browse/datasolr-78

.

Ma non riesco a vedere cosa c'è che non va nella mia implementazione, ho provato tutti i tipi di combinazioni!Continua a segnalare che "la ricerca della proprietà non trovata" perché sta cercando di istanziare la query invece di riconoscere l'implementazione personalizzata.Qualcun altro può suggerire cosa c'è che non va in questo?

Questo è un riepilogo della struttura della classe e dell'interfaccia:

//custom interface definition
public interface CustomerDocumentRepositoryCustom {

  public List<CustomerDocument> search(String searchTerm, String sortBy, 
    int pageSize, HashMap<String, Object> facets, Pageable page);
}

// I've tried "CustomerDocumentRepositoryCustomImpl" and tried adding the Repository annotation here
public class CustomerDocumentRepositoryImpl implements CustomerDocumentRepositoryCustom {

  @Resource
  private SolrTemplate solrTemplate1;

  @Override
  public List<CustomerDocument> search(String searchTerm, String sortBy, 
    int pageSize, HashMap<String, Object> facets, Pageable page) {
  …
  }
}

/**
 * This is the SOLR repository handler
 */
public interface CustomerSolrCrudRepositoryImpl extends CustomerDocumentRepositoryCustom,
  SolrCrudRepository<CustomerDocument, String> {

    @Query("text:?0")
    public List<CustomerDocument> findByText(String searchString);
}
.

La parte rilevante della traccia dello stack di avvio è sotto:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property search found for type CustomerDocument!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75) ~[PropertyPath.class:?]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) ~[PropertyPath.class:?]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) ~[PropertyPath.class:?]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) ~[PropertyPath.class:?]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241) ~[PropertyPath.class:?]
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[Part.class:?]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:213) ~[PartTree$OrPart.class:?]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:321) ~[PartTree$Predicate.class:?]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:301) ~[PartTree$Predicate.class:?]
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:82) ~[PartTree.class:?]
    at org.springframework.data.solr.repository.query.PartTreeSolrQuery.<init>(PartTreeSolrQuery.java:36) ~[PartTreeSolrQuery.class:?]
    at org.springframework.data.solr.repository.support.SolrRepositoryFactory$SolrQueryLookupStrategy.resolveQuery(SolrRepositoryFactory.java:130) ~[SolrRepositoryFactory$SolrQueryLookupStrategy.class:?]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:320) ~[RepositoryFactorySupport$QueryExecutorMethodInterceptor.class:?]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:169) ~[RepositoryFactorySupport.class:?]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224) ~[RepositoryFactoryBeanSupport.class:?]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210) ~[RepositoryFactoryBeanSupport.class:?]
    at org.springframework.data.solr.repository.support.SolrRepositoryFactoryBean.afterPropertiesSet(SolrRepositoryFactoryBean.java:66) ~[SolrRepositoryFactoryBean.class:?]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) ~[AbstractAutowireCapableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ~[AbstractAutowireCapableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[AbstractAutowireCapableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[AbstractAutowireCapableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[AbstractBeanFactory$1.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[DefaultSingletonBeanRegistry.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[AbstractBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) ~[AbstractBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:446) ~[CommonAnnotationBeanPostProcessor.class:4.0.6.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:420) ~[CommonAnnotationBeanPostProcessor.class:4.0.6.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:545) ~[CommonAnnotationBeanPostProcessor$ResourceElement.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:155) ~[InjectionMetadata$InjectedElement.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[InjectionMetadata.class:4.0.6.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:305) ~[CommonAnnotationBeanPostProcessor.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) ~[AbstractAutowireCapableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[AbstractAutowireCapableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[AbstractAutowireCapableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[AbstractBeanFactory$1.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[DefaultSingletonBeanRegistry.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[AbstractBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[AbstractBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017) ~[DefaultListableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) ~[DefaultListableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858) ~[DefaultListableBeanFactory.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ~[AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[InjectionMetadata.class:4.0.6.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ~[AutowiredAnnotationBeanPostProcessor.class:4.0.6.RELEASE]
    ... 56 more
.

È stato utile?

Soluzione

Oh non importa, l'ho capito alla fine.Ho dovuto rinominare il repository di base per CustomerDocumentRepository e ha iniziato a lavorare.

Questa convenzione è così poco chiara nella documentazione per i repository personalizzati!Tutto ciò che menziona è aggiungere Impl all'attuazione della classe personalizzata.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top