Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: "Only root path are allowed" since update from 2.8.1 to 2.9.0 (2.8.2 has same issue) #333

kienerj opened this issue Jan 30, 2013 · 3 comments


Copy link

@kienerj kienerj commented Jan 30, 2013

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

Class<? extends EntityPathBase<T>> compoundQueryClass

This is used to cast the QCompound instance to it's according subclass:

QCompound compound = QCompound.compound;

EntityPathBase<T> concreteCompound =;

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:

org.springframework.dao.InvalidDataAccessApiUsageException: Only root paths are allowed for joins : compound; nested exception is java.lang.IllegalArgumentException: Only root paths are allowed for joins : compound

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 =
new PathBuilder<>(ConcreteCompound.class, "compound")

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.

Copy link

@timowest timowest commented Jan 31, 2013

The problem is that doesn't create a root path anymore. The created path is connect to it's parent, so it's not a root path. 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

QCompound compound = new QCompound(path);

instead of

EntityPathBase<T> concreteCompound =;

Alternatively you can also go through the _super field chain of the subtype.

Copy link

@timowest timowest commented Feb 2, 2013

I just made sure that this works now

QCompound compound = QCompound.compound;
EntityPathBase<T> concreteCompound =; 

Delegates to root paths are now also treated as root paths.

Copy link

@timowest timowest commented Feb 20, 2013

Released in 3.0.0.BETA2

@timowest timowest closed this Feb 20, 2013
@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants