I am using EclipseLink
over Spring Boot
and have this jpql in a repository:
@Query("select function('pMonth',p.payDay) ,sum(p.price) " +
"from FullPayment p where " +
"group by function('pMonth', p.payDay)"
)
List<Object[]> paymentMonthlyHistory();
but it does not send the operator p.payDay
calling my custom function pMonth
. Here is the database error:
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect number of arguments for FUNCTION adventure_db.pMonth; expected 1, got 0
Error Code: 1318
Call: SELECT pMonth(), SUM(PRICE) FROM panel_fullPayment WHERE ((PAYDATE >= ?) AND (TRANSACTIONAMOUNT >= PRICE)) GROUP BY pMonth()
bind => [1 parameter bound]
I use Mysql
as DBMS. Any help would be appreciated
The problem was a typo. The field name is payDate
but I wrote p.payDay
. I put the answer here to emphasize that if you mistype the field name here, it won't show you an error on boot, but will generate a wrong query.