when i use this query then always show error why? am using MappedSuperclass in audit class.
@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 class looks
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Transaction extends Audit {
private Long Id;
}
and audit class is
@MappedSuperclass
public class Audit {
@Column(name = "createdDate", columnDefinition = "TIMESTAMP WITH TIME ZONE")
@CreatedDate
@JsonSerialize(using = CustomDateSerializer.class)
private LocalDateTime createdDate;
}
Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract java.util.List com.brite.repository.InstrumentRepository.getInstrumentForCurrencyConverstion(java.lang.String,java.time.LocalDateTime) but parameter 'Optional[createdDate]' not found in annotated 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
enter code here
pf.createdDate =: createdDenter code here
ate) and hd.dateTime =enter code here
(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)'!
It seems to me you are passing Optional Argument to method. That might be causing problems.
thanx, something was wrong with my query. we don't need to put space after colon ':' in query
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.