У меня JPA Spring boot.Я хочу динамическое ИЛИ И Запрос Как "выбрать столбец из таблицы, где условие1 = что-то1 || condtion2 = что-то2 ... || условиеN = что-тоN" Я использую составной репозиторий.
OtherRepositoryCustomImpl.java
@Service
public class OtherRepositoryCustomImpl implements OtherRepositoryCustom{
@PersistenceContext
private EntityManager entityManager;
@Override
public List<Person> findUserFromLocus() {
String query = "select * from Person";
return entityManager.createQuery(query).getResultList();
}
}
OtherRepositoryCustom.java
public interface OtherRepositoryCustom {
List<Person> findUserFromLocus();
}
OtherRepository.java
public interface OtherRepository extends CrudRepository<Person, String>, OtherRepositoryCustom {
//my function query
}
OtherService.java
@Service
public class OtherService {
@Autowired
private OtherRepository repository;
public List<String> getAllAutosomalKit() {
return repository.findDistinctAutosomalKit();
}
public List<String> getAllYKit() {
return repository.findDistinctYKit();
}
public List<String> getAllXKit() {
return repository.findDistinctXKit();
}
public List<String> getAllLocusAutosom() {
return repository.findLocusAutosom();
}
public List<String> getAllLocusY() {
return repository.findLocusY();
}
public List<String> getAllLocusX() {
return repository.findLocusX();
}
public List<Object[]> getStatsGraph(String locus, String table) {
if (table.equalsIgnoreCase("Autosom")) {
return repository.findStatsGraphA(locus);
} else if (table.equalsIgnoreCase("Y_STRs")) {
return repository.findStatsGraphY(locus);
} else if (table.equalsIgnoreCase("X_STRs")) {
return repository.findStatsGraphX(locus);
} else {
return null;
}
}
public List<Person> testSearchLocus(){
return repository.findUserFromLocus();
}
}
, и есть Ошибка
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'otherService': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'otherRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query method public abstract java.util.List io.forensic.springboot.Kit.OtherRepositoryCustom.findUserFromLocus()! No property findUserFromLocus found for type Person!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:364) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1269) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124) ~[spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.19.RELEASE.jar:1.5.19.RELEASE]
at io.forensic.springboot.TheRealApiApplication.main(TheRealApiApplication.java:16) [classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'otherService': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'otherRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query method public abstract java.util.List io.forensic.springboot.Kit.OtherRepositoryCustom.findUserFromLocus()! No property findUserFromLocus found for type Person!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:364) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1269) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'otherRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query method public abstract java.util.List io.forensic.springboot.Kit.OtherRepositoryCustom.findUserFromLocus()! No property findUserFromLocus found for type Person!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
... 32 common frames omitted
Caused by: java.lang.IllegalArgumentException: Failed to create query method public abstract java.util.List io.forensic.springboot.Kit.OtherRepositoryCustom.findUserFromLocus()! No property findUserFromLocus found for type Person!
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:76) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:101) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:207) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:451) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:223) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
... 42 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findUserFromLocus found for type Person!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:80) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:336) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:312) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:275) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:246) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:247) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:398) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:378) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:86) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:70) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
... 52 common frames omitted
, есть ошибки во время выполнения.Что я делаю не так?