Skip to content
Advertisement

Why I get: ‘%’, ‘(‘, , , ‘?’, FUNCTION or identifier expected, got ‘(‘?

I get an error in my Repository in Java Springboot.

In my controller I get the chosen categorie from the html page. I want to make a list of opleiding that covers the criteria of that categorie.

To make that list I call a query: GeefEenLijstvanCategorie(categorie):

String categorie = request.getParameter("categorie");
List<Opleiding> list = opleidingRepository.GeefEenLijstvanCategorie(categorie);

But I get an error in the Repository. The repository and queries in My Sql is all very new to me.

In the repository I have:

@Query("select o from Opleiding o where o.thema LIKE (String categorie)")
List<Opleiding> GeefEenLijstvanCategorie(String categorie);

This error occurs, positioned between the LIKE and (String categorie):

%', '(', <expression>, <input parameter>, '?', FUNCTION or identifier expected, got '('

Advertisement

Answer

Use : to use the value of a parameter.

@Query("select o from Opleiding o where o.thema LIKE '%:categorie%'")
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement