@QueryInit not working with deep nested paths
See original GitHub issueI am using QueryDSL 4.1.4 with Spring Data in a project and am having trouble using it with nested paths. Consider the following JPA classes:
@Entity @QueryEntity class Company {}
@Entity
@QueryEntity
class Contract {
@ManyToOne
@QueryInit("*.*")
Company buyer;
@ManyToOne
@QueryInit("*.*")
Company seller;
}
@Entity @QueryEntity class Bill { @ManyToOne @QueryInit("*.*") Contract contract; }
@Entity @QueryEntity class Payment { @ManyToOne @QueryInit("*.*") Bill bill; }
@Entity @QueryEntity class Posting { @ManyToOne @QueryInit("*.*") Payment payment; }
With this set up, the following throws NullPointerException
:
QPosting.posting.payment.bill.contract.buyer.name.equalsIgnoreCase(...)
Debugging shows that QPosting.posting.payment.bill.contract.buyer
(and QPosting.posting.payment.bill.contract.seller
) is null
.
The following however work fine:
QPayment.payment.bill.contract.buyer.name.equalsIgnoreCase(...)
QBill.bill.contract.buyer.name.equalsIgnoreCase(...)
QContract.contract.buyer.name.equalsIgnoreCase(...)
I am using com.mysema.maven:apt-maven-plugin:1.1.1
and QueryDSL version 4.1.4.
A full sample project is available here. Run Maven tests as mvn clean test
to see the error.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:12 (1 by maintainers)
Top Results From Across the Web
spring - How to use @QueryInit to init path to attribute of ...
Has anyone use @QueryInit to fix a problem similar to mine ? ... b.a.id and a.amount <= sum(b.amount))]; nested exception is java.lang.
Read more >Null property in metadata for nested entities - Launchpad Bugs
You can declare via annotations which deep paths are to be initialized or use accessor methods for entity references.
Read more >What Can Querydsl Do for Me Part 2: Multi-Tenant Application ...
Now that we know the problem and have a better understanding of initialization path limitations in Querydsl, we have a one-line fix to...
Read more >3.2. Configuration - Querydsl
In cases where longer initialization paths are required, these have to be ... QueryInit is used on properties where deep initializations are needed....
Read more >Query with multiple nested filter on same path not working
I have a query where there are 2 nested filters as follows (generated via Java API): GET pay/_search { "size" : 1000, "query"...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just encountered the same issue in my model.
I get a
NullPointerException
when callingupisaniPredmet.upisaniElement.upis.student
.upisaniPredmet.upisaniElement
is not null.upisaniPredmet.upisaniElement.upis
is not null.upisaniPredmet.upisaniElement.upis.student
is null.I have exactly the same problem. Must be the bug