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

Selecting JPAExpressions.type throws java.lang.ClassCastException #2034

Closed
tox87 opened this issue Oct 9, 2016 · 2 comments
Closed

Selecting JPAExpressions.type throws java.lang.ClassCastException #2034

tox87 opened this issue Oct 9, 2016 · 2 comments

Comments

@tox87
Copy link

tox87 commented Oct 9, 2016

I am trying to fetch entity class by id (single table inheritence), but query:
from(DOCUMENT).select(JPAExpressions.type(DOCUMENT)).where(DOCUMENT.id.eq(id)).fetchOne();
throws java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String

Debugging AbstractJPAQuery#getSingleResult shows that I get java.lang.Class but fetchOne casts it to string since JPAExpressions.type(DOCUMENT) returns StringExpression.

QueryDSL-JPA 4.1.4

Looks like the root cause can be the same for #1747

@stale
Copy link

stale bot commented Jun 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 3, 2021
@stale stale bot closed this as completed Jun 10, 2021
@flokle
Copy link

flokle commented Nov 16, 2022

If anyone should encounter the same problem:

Expressions.dslTemplate(Class.class, "type({0})", path)

Did it for me. Seems to be a very similar solution to the fix proposed in #1747

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants