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

count query issue in spring-data-jpa-2.5.11 #2511

Closed
lavanya2290 opened this issue Apr 27, 2022 · 8 comments
Closed

count query issue in spring-data-jpa-2.5.11 #2511

lavanya2290 opened this issue Apr 27, 2022 · 8 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@lavanya2290
Copy link

When we check our native query an issue comes
the count uery changes from select count(*) from tablename to select count(order) from tablename.

2.5.9...2.5.11#diff-7d36425745042f8c27507657de795fd7cf1d546da6a740fd00d86add46f81ed4R530

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 27, 2022
@lavanya2290
Copy link
Author

Screenshot 2022-04-27 at 4 30 48 PM

Screenshot 2022-04-27 at 4 30 40 PM

@lavanya2290
Copy link
Author

Matcher matcher = COUNT_MATCH.matcher("SELECT * FROM context ORDER BY time");
String countQuery;

	if (countProjection == null) {

		String variable = matcher.matches() ? matcher.group(VARIABLE_NAME_GROUP_INDEX) : null;
		boolean useVariable = StringUtils.hasText(variable) //
				&& !variable.startsWith(" new") //
				&& !variable.startsWith("count(") //
				&& !variable.contains(",") //
				&& !variable.contains("*");

		String complexCountValue = matcher.matches() && StringUtils.hasText(matcher.group(COMPLEX_COUNT_FIRST_INDEX))
				? COMPLEX_COUNT_VALUE
				: COMPLEX_COUNT_LAST_VALUE;

		String replacement = useVariable ? SIMPLE_COUNT_VALUE : complexCountValue;
		countQuery = matcher.replaceFirst(String.format(COUNT_REPLACEMENT_TEMPLATE, replacement));

DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jpa that referenced this issue Apr 28, 2022
In commit 3e64d9a a bug got introduced that uses the next symbol after the table name for the count function. With this commit this should be now resolved. The count query will use `*` when there is no alias present nor a variable.

Related tickets spring-projects#2177, spring-projects#2260, spring-projects#2511
gregturn pushed a commit that referenced this issue May 4, 2022
In commit 3e64d9a a bug got introduced that uses the next symbol after the table name for the count function. With this commit this should be now resolved. The count query will use `*` when there is no alias present nor a variable.

Related tickets #2341, #2177, #2260, #2511
gregturn pushed a commit that referenced this issue May 4, 2022
In commit 3e64d9a a bug got introduced that uses the next symbol after the table name for the count function. With this commit this should be now resolved. The count query will use `*` when there is no alias present nor a variable.

Related tickets #2341, #2177, #2260, #2511
gregturn pushed a commit that referenced this issue May 4, 2022
In commit 3e64d9a a bug got introduced that uses the next symbol after the table name for the count function. With this commit this should be now resolved. The count query will use `*` when there is no alias present nor a variable.

Related tickets #2341, #2177, #2260, #2511
gregturn pushed a commit that referenced this issue May 4, 2022
In commit 3e64d9a a bug got introduced that uses the next symbol after the table name for the count function. With this commit this should be now resolved. The count query will use `*` when there is no alias present nor a variable.

Related tickets #2341, #2177, #2260, #2511
@gregturn
Copy link
Contributor

gregturn commented May 4, 2022

#2514 has been backported to 2.5.x. Does this issue persist @lavanya2290 ?

@gregturn gregturn added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels May 4, 2022
@lavanya2290
Copy link
Author

lavanya2290 commented May 10, 2022

in 2.5.13 spring boot which uses 2.5.11 issue is there.
also is there any new release I can check

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 10, 2022
@Axinet
Copy link

Axinet commented Jun 17, 2022

#2495 is still open, so the only option as for now is downgrade to spring-data-jpa 2.5.10

@gregturn
Copy link
Contributor

Support for 2.5.x ended back in April. I'm closing this ticket for now. If you are still running into this issue on 2.6.x+, then please open a new ticket with details.

@gregturn gregturn added status: declined A suggestion or change that we don't feel we should currently apply and removed status: feedback-provided Feedback has been provided labels Sep 29, 2022
@lavanya2290
Copy link
Author

lavanya2290 commented Oct 11, 2022 via email

@Axinet
Copy link

Axinet commented Oct 11, 2022

As mentioned above, support for 2.5.x line has ended in April. You either have to upgrade to 2.6 line, or if you can't, revert to previous version in 2.5 line without that bug.
Recent 2.6.x versions don't have this bug any longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

4 participants