我试图在Spring Data JPA中创建存储库方法,如:
List<MemberSubscription> findAllByOrderByCreatedAsc(Example<MemberSubscription> memberSubscription);
但它给我错误:
Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.abcfinancial.api.subscription.repository.SubscriptionMembersRepository.findAllByOrderByCreatedAsc(org.springframework.data.domain.Example)! At least 1 parameter(s) provided but only 0 parameter(s) present in query.
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:82)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:103)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:208)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:79)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lookupQuery(RepositoryFactorySupport.java:553)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(RepositoryFactorySupport.java:546)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1049)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.mapMethodsToQuery(RepositoryFactorySupport.java:548)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$new$0(RepositoryFactorySupport.java:538)
at java.util.Optional.map(Optional.java:215)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:538)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:317)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$3(RepositoryFactoryBeanSupport.java:286)
at org.springframework.data.util.Lazy.getNullable(Lazy.java:141)
at org.springframework.data.util.Lazy.get(Lazy.java:63)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:289)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:102)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695)
... 60 common frames omitted
Caused by: java.lang.IllegalArgumentException: At least 1 parameter(s) provided but only 0 parameter(s) present in query.
at org.springframework.util.Assert.isTrue(Assert.java:134)
at org.springframework.data.jpa.repository.query.QueryParameterSetterFactory$CriteriaQueryParameterSetterFactory.create(QueryParameterSetterFactory.java:289)
at org.springframework.data.jpa.repository.query.ParameterBinderFactory.lambda$createQueryParameterSetter$1(ParameterBinderFactory.java:139)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createQueryParameterSetter(ParameterBinderFactory.java:141)
at org.springframework.data.jpa.repository.query.ParameterBinderFactory.lambda$createSetters$0(ParameterBinderFactory.java:131)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createSetters(ParameterBinderFactory.java:132)
at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createSetters(ParameterBinderFactory.java:124)
at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createCriteriaBinder(ParameterBinderFactory.java:75)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.getBinder(PartTreeJpaQuery.java:248)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.<init>(PartTreeJpaQuery.java:147)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$CountQueryPreparer.<init>(PartTreeJpaQuery.java:268)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:77)
... 86 common frames omitted
表格:
CREATE TABLE public.member_subscription
(
loc_id uuid NOT NULL,
mesu_created timestamp(6) without time zone NOT NULL DEFAULT now(),
mesu_deactivated timestamp(6) without time zone,
m_id uuid NOT NULL,
sub_id uuid NOT NULL,
CONSTRAINT fk_member_subscription_subscription FOREIGN KEY (sub_id)
REFERENCES public.subscription (sub_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT composite_unique_member_subscription UNIQUE (m_id, sub_id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.member_subscription
OWNER TO platformuser;
我想用create(即创建日期)按排序顺序查找表中的所有数据。
Spring 数据查询参数将根据其位置进行替换。但这可能会出错,绑定可能容易出错。因此,建议在方法参数中使用@Param注释来绑定查询参数名称。在查询中,您需要使用:p aramName来指示相同的参数名称将与方法参数绑定
@Entity
public class ABCConfig {
@EmbeddedId
private ABCConfigPK id;
@Embeddable
public class ABCConfigPK {
private Long ABCTypeId;
private String cId;
@Repository
public interface SpringDataABCConfigRepository extends CrudRepository<ABCConfig, ABCConfigPK> {
List<ABCConfig> findByIdABCTypeIdAndcardId(Long ABCTypeId,Long cId);
当我使用JAP接口JpaSpecificationExecutor时,我键入以下代码并抛出一个错误“至少提供了2个参数,但查询中只存在1个参数”,我不知道为什么。 我只想获得动态条件下的结果。异常消息如下:
问题内容: 我正在使用Python 3.6,flask,pyodbc,并连接到SQL Server。 我试图建立与数据库的连接,然后创建带有参数的查询。 这是代码: app.py register.html 当我运行程序时,出现此错误: pyodbc.ProgrammingError:(’SQL包含0个参数标记,但是提供了3个参数’,’HY000’) 问题答案: pyodbc使用,而不是作为参数占
我试图在JUnit 5中开发一个参数化测试,如下例所示。 尝试运行测试导致异常: 您必须为此@ParameterizedTest提供至少一个参数 这个信息让我觉得,我做错了什么,不是吗? p、 我有一个假设,只有原语类型的参数可用。
问题内容: 每次运行此php时,我都会不断收到相同的3个错误。我不知道我在做什么错,有人可以帮忙吗? 错误如下: [2014年5月5日19:20:50美国/芝加哥] PHP警告:mysqli_query()至少需要2个参数,第10行的/home/sagginev/public_html/Nutrifitness/search.php中提供了1个参数 [2014年5月5日19:20:50美国/芝加哥
我试图在我的services.yaml中为ImageManager.php获取一个参数,但它不起作用,我无法解决此错误。 错误是这样的: 类型错误:参数太少,无法运行App\Manager\ImageManager::__construct(),0在C:\wamp64\www\SymfonyAPI\var\ache\dev\ContainerZxFSS5S\getImageManagerServi
我正在试图理解JUnit 5,并借助一个带有JUnit 5的FizzBuzz应用程序。下面是一个测试用例 通过引发以下异常,此测试用例无法执行 根本原因可能是什么?