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

An error occurred in the case expression #1795

Closed
wang3develop opened this issue Sep 2, 2023 · 2 comments
Closed

An error occurred in the case expression #1795

wang3develop opened this issue Sep 2, 2023 · 2 comments

Comments

@wang3develop
Copy link

I seem to have written in the wrong place

querydsl/querydsl#3573

@jwgmeligmeyling
Copy link
Collaborator

Well the error comes from Hibernate and not Querydsl nor Blaze-Persistence 🤷🏻

I believe type inference of parameters inside case statements has always been problematic in Hibernate. Try wrapping the numbers in a JPQLNextExpressions.literal(value) to force literal rendering.

@wang3develop
Copy link
Author

Ok, thanks!
Perhaps I have found out how to handle it:

result = queryFactory.select(
					new CaseBuilder()
						.when(qod.dist.sum().intValue().eq(JPQLNextExpressions.literal(0)))
						.then(1)
						.when(qod.dist.sum().intValue().eq(qod.need.sum().intValue()))
						.then(2)
						.otherwise(0)
				)
				.from(qod)
				.where(qod.code.eq(no))
				.fetchFirst();

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

No branches or pull requests

2 participants