Exception: "Only root path are allowed" since update from 2.8.1 to 2.9.0 (2.8.2 has same issue) #333
I have a generic spring-data repository. That repository can be used to query for any subclass of a specific type, Compound. The find method has a parameter of type
This is used to cast the QCompound instance to it's according subclass:
Then the query is created:
This worked perfectly fine with QueryDSL 2.8.1 and if compoundQueryClass was of type QSubclass1, only Subclass1 objects were returned, if it was of QSubclass2, only Subclass2 objects were returned. You get the point.
If I update to QueryDSL 2.9.0 (or 2.8.2) the line
throws an error:
and if I use
the query returns all compounds, regardless of their concrete types.
Note: it says it's a spring exception but I only changed QueryDSL version. So the cause must lie within QueryDSL as the issue did not occur in 2.8.1
My current solution is to use a PathBuilder instead:
PathBuilder entityPath =
I think the issue is the actual name of the path, eg. "compound" in base class and "concreteCompound" in sub class. That is probably why it works when using the PathBuilder with path name "compound" for concrete compound.
The text was updated successfully, but these errors were encountered:
The problem is that path.as(QType) doesn't create a root path anymore. The created path is connect to it's parent, so it's not a root path.
path.as(Class) is more of a Querydsl level cast than the creation of a copy, I will try to simplify the semantics.
But in your case why don't you supply the path of the concrete type instead?
This will give you
Alternatively you can also go through the _super field chain of the subtype.