Попытка объединения двух таблиц в списке объектов с использованием этого запроса JPA.
Я получаю эту ошибку:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: agreement_customers is not mapped
Как решить эту проблему, не используя @Entity
для СоглашенияMergeTable (я не хочу создавать новую таблицу в моей базе данных).
Обратите внимание, что нормальные репозитории работают нормально со всеми классами.
Agreement_Custome_Repository. java
public interface Agreement_Custome_Repository extends CrudRepository<Agreement_customers, String > {
@Query(value = "SELECT new com.fees.model.AgreementsMergeTable"+
"(customerNumber(ac.customer_number),agreementSerial(ac.agreement_serial),agreementStartDate(a.agreement_start_date), agreementEndDate(a.agreement_end_date) ,agingPeriod(a.aging_period) ,minNoSubs (a.min_no_subs))"+
"from agreement_customers ac , agreements a WHERE ac.agreement_serial = a.agreement_serial and ac.status = 0 and a.status = 0")
List<AgreementsMergeTable> getStaticsAgreementsMergeTable();
}
СоглашенияMergeTable. java
package com.fees.model;
import java.util.Date;
public class AgreementsMergeTable {
private int customerNumber;
private String agreementSerial;
private Date agreementStartDate;
private Date agreementEndDate;
private int agingPeriod;
private int minNoSubs;
public AgreementsMergeTable(int customerNumber, String agreementSerial, int status, Date agreementStartDate,
Date agreementEndDate, int agingPeriod, int minNoSubs) {
this.customerNumber = customerNumber;
this.agreementSerial = agreementSerial;
this.agreementStartDate = agreementStartDate;
this.agreementEndDate = agreementEndDate;
this.agingPeriod = agingPeriod;
this.minNoSubs = minNoSubs;
}
}
Соглашение_клиенты. java
package com.fees.model;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="agreement_customers")
public class Agreement_customers
{
private String agreementSerial;
@Id
private int customerNumber;
private int status;
public Agreement_customers() {
}
public Agreement_customers(String agreementSerial, int customerNumber, int status) {
this.agreementSerial = agreementSerial;
this.customerNumber = customerNumber;
this.status = status;
}
Соглашения. java
package com.fees.model;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Agreements {
private String agreementName;
@Id
private String agreementSerial;
private int status;
private Date agreementStartDate;
private Date agreementEndDate;
private int agingPeriod;
private int minNoSubs;
public Agreements() {
}
public Agreements(String agreementName, String agreementSerial, int status, Date agreementStartDate,
Date agreementEndDate, int agingPeriod, int minNoSubs) {
this.agreementName = agreementName;
this.agreementSerial = agreementSerial;
this.status = status;
this.agreementStartDate = agreementStartDate;
this.agreementEndDate = agreementEndDate;
this.agingPeriod = agingPeriod;
this.minNoSubs = minNoSubs;
}
}