I having trouble doing a custom query with spring-data-mongo repository.
I have the next code:
@RestResource
public interface RecipeRestRepository extends MongoRepository<Recipe, String> {
@Query(value = "{'title': {$regex : ?0, $options: 'i'}}")
public List<Recipe> findByTitleRegex(String titleRegex);
}
and when I query that method give me spring gives me the next error:
java.lang.IllegalArgumentException: Unable to detect parameter names for query method com.arturo.chefioapi.recipe.RecipeRestRepository.findByTitleRegex! Use @Param or compile with -parameters on JDK 8.
I also used @Param but gives me the following error:
java.lang.NullPointerException: null
at java.util.regex.Pattern.<init>(Pattern.java:1350) ~[na:1.8.0_222]
at java.util.regex.Pattern.compile(Pattern.java:1054) ~[na:1.8.0_222]
Also I tried to compile with -parameters using:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<parameters>true</parameters>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
Thanks in advance.