Describe the bug
If a repository method addresses a nested entities Quarkus cannot parse the method.
Given the follwing JPA entities:
@Entity
@Table(name = "RACE_TEAMS")
public class RaceTeamEntity {
@Id
@Column(name = "ID", length = 26)
private String id;
@Column(name = "NAME", nullable = false, length = 256)
private String name;
...
}
@Entity
@Table(name = "RACE_CAR_DRIVERS")
public class RaceCarDriverEntity {
@Id
@Column(name = "ID", length = 26)
private String id;
@ManyToOne
@JoinColumn(name = "RACE_TEAM_ID", nullable = false)
private RaceTeamEntity team;
@Column(name = "NAME", nullable = false, length = 256)
private String name;
}
@Entity
@Table(name = "CLASSIC_CARS")
public class ClassicCarEntity {
@Id
@Column(name = "CLASSIC_CAR_ID", length = 26)
private String id;
@ManyToOne
@JoinColumn(name = "BRAND_ID", nullable = false)
private CarBrandEnity carBrand;
@ManyToOne
@JoinColumn(name = "DRIVER_ID", nullable = false)
private RaceCarDriverEntity driver;
@Column(name = "NAME", nullable = false, length = 256)
private String name;
}
The repository method findByRaceCarDriverTeamName should find the RaceCarEntity by the Name of the Driver's RaceTeam
@Repository
public interface ClassicCarRepository extends JpaRepository<ClassicCarEntity, String> {
List<ClassicCarEntity> findByRaceCarDriverTeamName(String teamName);
}
But instead throws UableToParseMethodException: Entity org.acme.resteasy.entities.ClassicCarEntity does not contain a field named: raceCarDriverTeamName. Offending method is findByRaceCarDriverTeamName
Expected behavior
Camel-case properties can be used as in Spring Data and sub-properties are correctly matched (e.g. the expression tomatoSpagettiSauceColor could mean tomato.spagehtti.sauce.color or tomatoSpaghetti.sauce.color or tomatoSpaghetti.sauceColor or tomato.spaghetti.sauceColor or tomato.spaghettiSauce.coloror ...)
See https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-property-expressions
Actual behavior
An UnableToParseMethodExceptionis thrown if nested camel-case property address sub-entities.
To Reproduce
Checkout https://github.com/renegrob/spring-data-jpa-repo-method-issue
Steps to reproduce the behavior:
./mvnw compile quarkus:dev on the command lineError in the console output:
2020-11-02 16:33:45,534 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.spring.data.deployment.SpringDataJPAProcessor#build threw an exception: io.quarkus.spring.data.deployment.UnableToParseMethodException: Entity org.acme.resteasy.entities.ClassicCarEntity does not contain a field named: raceCarDriverTeamName. Offending method is findByRaceCarDriverTeamName
Screenshots
n/a
Environment (please complete the following information):
uname -a or ver: $ uname -a
Linux automatix 5.4.0-52-generic #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
java -version: $ java -version
openjdk version "11.0.9" 2020-10-20 LTS
OpenJDK Runtime Environment Zulu11.43+21-CA (build 11.0.9+11-LTS)
OpenJDK 64-Bit Server VM Zulu11.43+21-CA (build 11.0.9+11-LTS, mixed mode)
1.9.1.Finalmvnw --version or gradlew --version): ./mvnw --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/gro/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 11.0.9, vendor: Azul Systems, Inc., runtime: /usr/lib/jvm/zulu11-ca-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-52-generic", arch: "amd64", family: "unix"
Additional context
n/a
/cc @geoand
@aureamunoz would you like to take a look at this one?
Yep! will do
Thanks!
I solved the issue in my fork: https://github.com/renegrob/quarkus/tree/quarkus-issue-13067. Shall I create a draft pull request?
Sure thing!
Please ping myself and @aureamunoz on the PR because AFAIK she was planning on working on it as well.
@geoand @aureamunoz I pushed the pull request. On my fork the pipeline is not completely green but the errors don't seem to be related to the commit. I didn't add additional tests so far.