java.lang.IllegalStateException:使用命名参数

java.lang.IllegalStateException:使用命名参数,java,spring,hql,Java,Spring,Hql,当我使用此查询时,始终显示错误原因?我在审计类中使用MappedSuperclass @Query("select new com.brite.domain.CurrencyConversion(ins.id,ins.contractType,ins.symbol,ins.exchange,ins.currency,ap.allocationQty,ap.createdDate,ca.baseCurrency,hd.close) from ActualPortfolio as ap JOIN

当我使用此查询时,始终显示错误原因?我在审计类中使用MappedSuperclass

@Query("select new  com.brite.domain.CurrencyConversion(ins.id,ins.contractType,ins.symbol,ins.exchange,ins.currency,ap.allocationQty,ap.createdDate,ca.baseCurrency,hd.close) from ActualPortfolio as ap JOIN  Instrument as ins on ins.id=ap.instrument.id JOIN  HistoricalData as hd on hd.instrumentId = ins.id   Join ClientAccount as ca on ca.accountId = ap.clientAccount.accountId  where ap.clientAccount.accountId =:accountId and ap.createdDate = (select MAX(pf.createdDate) as date from ActualPortfolio pf where  ap.clientAccount.accountId =:accountId and pf.createdDate =: createdDate) and hd.dateTime = (select to_char(MAX(pf.createdDate), 'YYYY-MM-DD 00:00:00') as date from ActualPortfolio pf where  ap.clientAccount.accountId =:accountId and pf.createdDate =: createdDate)")
Pojo类外观

        @Entity
        @EntityListeners(AuditingEntityListener.class)
        public class Transaction extends Audit {    
            private Long Id;     

        }
审计课是

        @MappedSuperclass
        public class Audit {

            @Column(name = "createdDate", columnDefinition = "TIMESTAMP WITH TIME ZONE")
            @CreatedDate
            @JsonSerialize(using = CustomDateSerializer.class)
            private LocalDateTime createdDate;

        }
原因:java.lang.IllegalStateException:使用命名参数 方法public abstract java.util.List com.brite.repository.InstrumentRepository.GetInstrumentForCurrencyConversationJava.lang.String,java.time.LocalDateTime 但在带注释的查询中找不到参数“可选[createdDate]” '选择新 com.brite.domain.CurrencyConversionins.id、ins.contractType、ins.symbol、ins.exchange、ins.currency、ap.allocationQty、ap.createdDate、ca.baseCurrency、hd.close 从实际端口组合作为ap连接仪器作为ins on ins.id=ap.instrument.id将历史数据作为hd.instrumentId上的hd连接 =ins.id在ca.accountId=ap.ClientAccount.accountId其中ap.ClientAccount.accountId上作为ca加入ClientAccount =:accountId和ap.createdDate=从ActualPortfolio pf中选择MAXpf.createdDate作为日期,其中ap.clientAccount.accountId=:accountId andenter code here pf.createdDate=:createdCenter code hereate 和hd.dateTime=在此处输入代码选择 至_charMAXpf.createdDate,“YYYY-MM-DD 00:00:00”作为日期从 ActualPortfolio pf,其中ap.clientAccount.accountId=:accountId和 pf.createdDate=:createdDate'


在我看来,您正在将可选参数传递给方法。这可能会引起问题

在我看来,您正在将可选参数传递给方法。这可能会引起问题

thanx,我的问题出了点问题。在查询中,不需要在冒号“:”后面加空格,因为我的查询有问题。在查询中,我们不需要在冒号“:”后面加空格,请发布带注释的方法签名。可能您的存储库参数createdDate没有注释@ParamcreatedDate,或者参数名称与以下答案中提到的hqlAs中的名称不同,您使用可选的创建日期作为参数。将其更改为允许展开日期对象。但是yiu还没有发布您的java部分代码。因此,请更正您的问题,以便他人帮助您。您应该在@queryy之后添加存储库方法签名。您最好从ActualPortfolio as ap JOIN Instrument as ins.id=ap.Instrument.id中删除类似的结构。您可以使用from ActualPortfolio ap JOIN ap.instrument ins或from ActualPortfolio ap,instrument INSTEAD,其中ins.id=ap.instrument.id INSTEAD请发布带注释的方法签名。可能您的存储库参数createdDate没有注释@ParamcreatedDate,或者参数名称与以下答案中提到的hqlAs中的名称不同,您正在使用可选的创建日期作为参数。将其更改为允许展开日期对象。但是yiu还没有发布您的java部分代码。因此,请更正您的问题,以便他人帮助您。您应该在@queryy之后添加存储库方法签名。您最好从ActualPortfolio as ap JOIN Instrument as ins.id=ap.Instrument.id中删除类似的结构。您可以使用from ActualPortfolio ap JOIN ap.instrument ins或from ActualPortfolio ap,instrument ins,其中ins.id=ap.instrument.id