Closed realfabianw closed 1 year ago
Hi @realfabianw you must compile your code with the -parameters
flag, otherwise the names of parameters will not be available.
IDK if this is still the right way to do it in Gradle
tasks.withType(JavaCompile) {
options.compilerArgs << '-parameters'
}
or if there's a better way. TBH I thought Spring Boot plugin does that automatically for you, the same way as Maven Spring Boot Plugin does.
You can alternatively use @Param
on the corresponding parameter and specify the name.
thanks @michael-simons for your quick reply. I think you're right. Now that i know what i'm looking for i actually found the warning that reports this behaviour:
2023-09-22T15:15:34.157+02:00 WARN 31720 --- [ main] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: com.error.gradle.MqttSourceRepository
I've tried to adjust my build.gradle file with your suggested fix but failed to get it working. The gradle docs mark the CompileOptions accessed through "options" as read only, which is weird. I've also tried to use the existing compileJava Task, but that also didn't work.
compileJava {
options.compilerArgs.add("-parameters")
}
Anyway, manually annotating the Parameter with the @Param
Tag solved my issue. Everything else is unchanged.
public interface MqttSourceRepository extends Neo4jRepository<MqttSource, String> {
@Query("MATCH (gateway: Gateway {nodeId: $gatewayId})-[*]-(sources: MqttSource) RETURN DISTINCT sources;")
List<MqttSource> findAllRelatedMqttSources(@Param("gatewayId") String gatewayId);
}
I will close this issue as my problems are resolved.
Hello,
I have been working on an IoT application for some time now and recently decided to switch from Maven to Gradle (Groovy) for dependency management. Unfortunately I can't get my code to run when using Gradle. I outsourced the affected part into two projects (Maven and Gradle) to be able to analyze the problem in more detail.
Neo4j (using Gradle) seems to have a problem resolving a custom query using the @Query annotation without errors. Both projects use the same code but only when using Gradle this code results in an error. See the complete setup below.
Gradle Project (Results in an error)
Maven Project (Works as expected)
As you can read in the build.gradle and pom.xml, i encountered this problem with Spring Boot Version 3.1.3. I've tested the recent 3.1.4 release and the problem persists. I really have no idea what exactly is triggering this error and would appreciate any help.
Kind Regards