Ниже моя сущность для представления vw_invoice_report
@Entity
@Table(name = "vw_invoice_report")
class Report implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id")
private Long id;
@Column(name = "sender_name")
private String sender;
@Column(name = "client_name")
private String client;
@Column(name = "submit_date")
@Temporal(TemporalType.TIMESTAMP)
private Date submitDate;
@Column(name = "invoice_num")
private String invoiceNum;
//getters
}
И я пытаюсь реализовать findByClientAndLawfirmAndSubmitDateBetween
для запроса представления, используя client,sender, submitDate
поля
public interface ReportRepository extends PagingAndSortingRepository<Report, Long>{
public List<Report> findByClientAndLawfirmAndSubmitDateBetween(String client, String sender, Date start, Date stop, Pageable pageable)
}
, когда Я пытаюсь вызвать вышеуказанный метод, получаю приведенную ниже ошибку
org.hibernate.QueryException: could not resolve property: client of: com.xyz.reports.Report
[select generatedAlias0 from com.xyz.reports.Report as generatedAlias0 where ( ( generatedAlias0.client=:param0 ) and ( generatedAlias0.sender=:param1 ) ) and ( generatedAlias0.submitDate between :param2 and :param3 )]; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: client of: com.xyz.reports.Report [select generatedAlias0 from com.xyz.reports.Report as generatedAlias0 where ( ( generatedAlias0.client=:param0 ) and ( generatedAlias0.sender=:param1 ) ) and ( generatedAlias0.submitDate between :param2 and :param3 )] 34178348919273527
Но если я аннотирую приведенный выше запрос аннотацией Query
, как показано ниже его рабочего штрафа
@Query(value="SELECT id, sender_name, client_name, submit_date, invoice_num FROM vw_invoice_report WHERE client_name = ?1 AND sender_name = ?2 AND submit_date BETWEEN ?3 AND ?4 ORDER BY submit_date desc",
nativeQuery = true)`
Есть ли в любом случае заставить findByClientAndLawfirmAndSubmitDateBetween()
работать без @Query