Skip to content

Clarify the @Lock on String-based queries #2008

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

Closed
wants to merge 1 commit into from

Conversation

mipo256
Copy link
Contributor

@mipo256 mipo256 commented Mar 10, 2025

Currently, the reference documentation states, that @Lock can be used with derived queries. But our documentation does not mention anywhere, that we do not support @Lock on string-based queries. I want to address this issue by altering the corresponding doc + issuing the warning log

P.S: @mp911de @schauder Maybe we can throw an exception? By the way, we're already actively doing so, check here.

My concern is that this will be a breaking change, although. Nevertheless, this is a fail fast approach, which is generally better. In addition, Spring Data JDBC 4 major release is coming, so, I think it is worth considering this option.

Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 10, 2025
@mp911de mp911de added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 10, 2025
schauder pushed a commit that referenced this pull request Mar 10, 2025
Original pull request #2008

Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>

Commit message edited.
schauder added a commit that referenced this pull request Mar 10, 2025
Refining documentation.

Original pull request #2008
@schauder
Copy link
Contributor

Thanks. That's merged.

And I agree on the error message. Do you want to prepare a PR for the 4.0.x branch?

@schauder schauder closed this Mar 10, 2025
@mipo256
Copy link
Contributor Author

mipo256 commented Mar 10, 2025

@schauder eah, sure. So we want to throw an exception since version 4.0.x, am I correct? If so, then I'll provide the corresponding PR

@schauder
Copy link
Contributor

Exactly. Thanks.

@@ -78,6 +80,8 @@
public class StringBasedJdbcQuery extends AbstractJdbcQuery {

private static final String PARAMETER_NEEDS_TO_BE_NAMED = "For queries with named parameters you need to provide names for method parameters; Use @Param for query method parameters, or use the javac flag -parameters";
private final static String LOCKING_IS_NOT_SUPPORTED = "Currently, @Lock is supported only on derived queries. In other words, for queries created with @Query, the locking condition specified with @Lock does nothing";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to reword the second part from a repetition to something actionable? I.e. "…include the database-specific locking hints in your query…"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I agree with you, @mp911de. I'll provide the PR with exception thrown for 4th major release shortly, and I'll apply your suggestion, what do you think?

schauder added a commit that referenced this pull request Apr 10, 2025
Formatting.
Added a test.

Original pull request #2023
See #2008
schauder added a commit that referenced this pull request Apr 25, 2025
Formatting.
Added a test.

Original pull request #2023
See #2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants