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

feat: Support adding @YdbType annotation to method parameters #173

Open
zdazzy opened this issue Feb 13, 2025 · 5 comments
Open

feat: Support adding @YdbType annotation to method parameters #173

zdazzy opened this issue Feb 13, 2025 · 5 comments
Assignees

Comments

@zdazzy
Copy link

zdazzy commented Feb 13, 2025

To cover the following (and all similar) case:

interface MyRepository extends ListCrudRepository<MyEntity, String> {

    @Query(
        """
        SELECT <....>
        <....>
        LIMIT :limit
        """
    )
    List<MyEntity> findWithLimit(@Param("limit") long limit);

}

The inferred limit parameter type here is Int64, while YDB requires it to be exaclty UInt64.

There are other cases where implicit type conversion fails. So a way to control this behavior would be great. An existing @YdbType annotation seems like a good solution.

@KirillKurdyukov KirillKurdyukov self-assigned this Feb 13, 2025
@mipo256
Copy link
Contributor

mipo256 commented Feb 17, 2025

@zdazzy Existing YdbMappingJdbcConverter should solve this. This custom JdbcConverter is applied on both named and positional parameters.

Have you extended the AbstractYdbJdbcConfiguration?

@zdazzy
Copy link
Author

zdazzy commented Feb 20, 2025

@mipo256 The annotation is currently only applicable to fields. Placing it on method parameter will result in a compilation error.
The issue has nothing to do with configuration.

@mipo256
Copy link
Contributor

mipo256 commented Feb 21, 2025

Yes, I got the general idea of what you're trying to do.

CC: @KirillKurdyukov please, add the pending-design tag for the issue

@mipo256
Copy link
Contributor

mipo256 commented Feb 21, 2025

The first top-level review of the problem unravels the following approach.

We can specify the custom RepositoryFactoryBeanSupport in the @EnableJdbcRepositories, extended from JdbcRepositoryFactoryBean likely. We need it to override the creation of the JdbcRepositoryFactory child that has it's own QueryLookupStrategy defined. And here, we can construct our own QueryMethod with our own implementation of getParameters().

That would solve the problem. However, there are a couple of caveats.

  1. This would require to extend a lot of stuff from the original Spring Data Commons/Spring Data JDBC infrastructure. That is generally not a big deal, since it is designed in this way specifically
  2. The larger problem is that the JdbcQueryLookupStrategy that is native to Spring Data JDBC, like CreateIfNotFoundQueryLookupStrategy, which is used by default, is not a public API. Therefore, we would have to extend RelationalQueryLookupStrategy and duplicate some code from the original source tree.

So, we need to think about it more deeply.

CC: @KirillKurdyukov

@mipo256
Copy link
Contributor

mipo256 commented Feb 21, 2025

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