Details
Assignee
UnassignedUnassignedReporter
Edward Lynch-MilnerEdward Lynch-MilnerComponents
Affects versions
Priority
Major
Details
Details
Assignee
Unassigned
UnassignedReporter
Edward Lynch-Milner
Edward Lynch-MilnerComponents
Affects versions
Priority
Created March 15, 2022 at 9:36 AM
Updated December 3, 2024 at 7:39 AM
I am having an invalid path issue with Hibernate and Spring JPA Criteria API. I have the following error:
Basically, the alias generatedAlias4 is presumably an alias that was meant to appear from a JOIN performed somewhere but the alias is not defined anywhere in the SQL leading to the error.
The SQL I am trying to emulate is:
I understand that might not be correct HQL (quickly wrote it to give a rough idea) but I am using the CriteriaQuery and CriteriaBuilder API to dynamically create the query.
The code creating the query is as follows:
It returns a Predicate for use in a Specification to search using a repository extending the JpaSpecificationExecutor interface. I used correlate to correlate the application root into the subquery, which theoretically means the last of the subquery where statement should be
where generatedAlias3.applicationId=generatedAlias0.applicationId
and notgeneratedAlias3.applicationId=generatedAlias4.applicationId
The query is meant to ask, find all Applications where a user with the username ‘test’ exists in the list of AssignedCommitteeMembers. The SubmittedApplication class is a subclass of the Application class (a class that represents an application form being created on the system) that contains a list with OneToMany mapping of these AssignedCommitteeMembers. The first I noticed, selects from the base Application class. Shouldn’t it be selected from the SubmittedApplication class? Could this be the issue?
select generatedAlias0 from ie.ul.ethics.scieng.applications.models.applications.Application as generatedAlias0
instead ofselect generatedAlias0 from ie.ul.ethics.scieng.applications.models.applications.SubmittedApplication as generatedAlias0
The entity for the SubmittedApplication class (with irrelevant properties stripped. The applicationId field is contained in the superclass Application. It is a String ID separate to the database ID used for application management):
The AssignedCommitteeMember class is here:
I was told by Christian Beikov that the issue has been fixed as of Version 6.0 but that is not compatible with Spring Boot yet. I have also tried the same query without the call to
correlate