IllegalArgumentException with JPA

0

I have this problem:

SELECT monthname (h.i_date) AS m FROM History h where year (now ()) GROUP BY month (h.i_date)

I execute this statement in mysql and there are no problems. But using JPA in java launches the second error:

[33, 34] The SELECT clause has 'monthname' and '(h.iDate) AS m' that are not separated by a comma. [70, 88] The expression is not a valid conditional expression. [102, 103] The GROUP BY clause has 'month' and '(h.iDate)' that are not separated by a comma.

I hope you can help me. Thanks.

    
asked by Alejandro 05.01.2018 в 17:22
source

1 answer

2

What happens is that in JPA to call the functions that the engine has, you must use FUNC () in the query, for example:

FUNC('MONTHNAME', h.iDate) 

This if you use EclipseLink 2.1, if you use EclipseLink 2.5 it would be:

FUNCTION('MONTHNAME', h.iDate)

I hope this helps you.

    
answered by 05.01.2018 / 18:12
source