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

提供 @AssembleDB 注解,支持基于自定义 SQL 的数据源容器 #40

Closed
1 of 2 tasks
Createsequence opened this issue Apr 10, 2023 · 0 comments
Closed
1 of 2 tasks
Labels
enhancement New feature or request primary This is an important feature or fix that needs to be completed as a top priority worth trying Features or improvements that are worth trying but not necessarily achievable
Milestone

Comments

@Createsequence
Copy link
Collaborator

Createsequence commented Apr 10, 2023

提供 Jdbc 扩展,支持基于自定义 SQL 的数据源容器,比如:

public class Foo {
    @AssembleQuery(
        selects = {"user_name", "user_age"}, where = "id", from = "user", // 可以构建查询 SQL,直接基于 PrepareStatement 查询
        datasource = "default_ds", // 可以选择数据源
        props = {
            @Mapping(src = "user_name", ref = "name"),
            @Mapping(src = "user_age", ref = "age")
        }
    )
    private Integer id;
    private String name;
    private String age;
}

上述配置等同于 select user_name, user_age where id in ?,查询后总是返回一个 List<Map<String, Object>> 集合。

最好也可以直接支持一下参数化 SQL,比如:

public class Foo {
    @AssembleQuery(
        sql = "select user_name, user_age where id in :keys",  // keys 是默认的键字段值,即 id 集合
        props = {
            @Mapping(src = "user_name", ref = "name"),
            @Mapping(src = "user_age", ref = "age")
        }
    )
    private Integer id;
    private String name;
    private String age;
}
  • 完成重构;
  • 修改文档;
@Createsequence Createsequence added enhancement New feature or request worth trying Features or improvements that are worth trying but not necessarily achievable labels Apr 10, 2023
@Createsequence Createsequence added this to the release 1.4.0 milestone Apr 10, 2023
@Createsequence Createsequence changed the title 提供 JdbcTemplate 扩展,支持基于自定义 SQL 的数据源容器 提供 Jdbc 扩展,支持基于自定义 SQL 的数据源容器 Jul 5, 2023
@Createsequence Createsequence changed the title 提供 Jdbc 扩展,支持基于自定义 SQL 的数据源容器 提供 @AssembleDB 注解,支持基于自定义 SQL 的数据源容器 Aug 13, 2023
@Createsequence Createsequence added the primary This is an important feature or fix that needs to be completed as a top priority label Oct 8, 2023
Createsequence added a commit that referenced this issue Jun 8, 2024
…g after querying data through custom SQL (GitHub #40)
Createsequence added a commit that referenced this issue Jun 8, 2024
…g after querying data through custom SQL (GitHub #40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request primary This is an important feature or fix that needs to be completed as a top priority worth trying Features or improvements that are worth trying but not necessarily achievable
Projects
None yet
Development

No branches or pull requests

1 participant