当我使用此查询时,总是显示错误为什么?在审计类中使用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:将命名参数用于 方法公共抽象java.util.List com.brite.repository.InstrumentRepository.getInstrumentForCurrencyConverstion(java.lang.String,java.time.LocalDateTime) 但是在带注释的查询中找不到参数“ Optional [createdDate]” '选择新 com.brite.domain.CurrencyConversion(ins.id,ins.contractType,ins.symbol,ins.exchange,inscurrency,ap.allocationQty,ap.createdDate,ca.baseCurrency,hd.close) 从ActualPortfolio那里作为ap JOIN Instrument从ins开始 ins.id = ap.instrument.id在hd.instrumentId上将HistoricalData作为hd加入 = ins.id以ca.accountId上的ca身份加入ClientAccount = ap.clientAccount.accountId,其中ap.clientAccount.accountId =:accountId和ap.createdDate =(选择MAX(pf.createdDate)作为ActualPortfolio pf中的日期,其中ap.clientAccount.accountId =:accountId 和
enter code here
pf.createdDate =:createdDenter code here
和hd.dateTime =enter code here
(选择 to_char(MAX(pf.createdDate),'YYYY-MM-DD 00:00:00')作为起始日期 ActualPortfolio pf,其中ap.clientAccount.accountId =:accountId和 pf.createdDate =:createdDate)'!
答案 0 :(得分:2)
在我看来,您正在将Optional Argument传递给方法。那可能会引起问题。
答案 1 :(得分:0)
谢谢,我的查询出了点问题。我们不需要在查询中的冒号':'后面放置空格