Skip to content
Advertisement

Using BETWEEN in native query in JPQL

I tried to make a query using BETWEEN in JPQL, I already tested it in SQL and it works, but when I implemented in JPQL I got an error:

I don’t understand why there is the error near :, can anybody help me figure it out?

Here is my code:

Advertisement

Answer

According to this answer, EclipseLink has slightly different syntax of setting named parameters in native queries using ? prefix instead of :

Other option is to use positional parameters 1 and 2 for tahun1 and tahun2 respectively:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement