sqlException : column not found JPA @query

Viewed 8534

I'm using @query annotation but when I try to fetch count of records it throws

java.sql.SQLException: Column 'allowPartialPay' not found.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1162) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.ResultSetImpl.getBoolean(ResultSetImpl.java:1781) ~[mysql-connector-java-5.1.31.jar:na]

I'm writing my custom queries in repository.

InvoiceRepository.java

public interface InvoiceRepository extends JpaRepository<Invoice, Integer>{

    Invoice findByInvoiceNumber(String invoiceNumber);

    List<Invoice> findByUserId(int id);

    @Query(value = "select c.id,c.business_name,count(i.id) from client c join invoice i on c.id = i.client_id where i.date <= :agingDate group by c.id",nativeQuery=true)
    List<Invoice> findInvoiceCount(@Param("agingDate")Date agingDate);

}

ReportService.java

if(report.getReportBy().equals("invoiceCount")){
                    result = invoiceRepository.findInvoiceCount(report.getAgingDate());
                }

Invoice.java

@Entity
@Table
public class Invoice {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="id")
    private int id;

    @ManyToOne
    private Client client;

    @Column
    private boolean allowPartialPay;
}

Database

enter image description here

1 Answers
Related