【问题标题】:Is there with micronaut a way to have the "Spring Data JPA" repository autogenerated from an interface like in spring?micronaut 有没有办法让“Spring Data JPA”存储库像在 spring 中那样从接口自动生成?
【发布时间】:2019-06-15 16:25:30
【问题描述】:

我正在使用 micronaut 设置一个新的微服务,并希望它通过 jpa/hibernate 访问数据库。

有没有一种简单的方法可以像使用 spring 一样从接口自动生成“Spring Data JPA”存储库实现?

interface ExampleRepository {
    fun FindById(id: String): Example
}

理想情况下,我可以通过 DI 将 ExampleRepository 导入到我的服务中。

编辑:Micronaut 数据正在发布中:https://github.com/micronaut-projects/micronaut-data

【问题讨论】:

    标签: hibernate kotlin spring-data-jpa repository-pattern micronaut


    【解决方案1】:

    目前还没有,尽管未来计划推出这样的功能。

    【讨论】:

      【解决方案2】:

      2019 年 7 月,Micronaut 作者发布了 Predator——Precomputed Data Repositories 的缩写——相当于 Spring Data。

      Quoting:

      Predator 使用 Micronaut 的提前 (AoT) 编译 API 将实体元模型移动到编译器中,并在编译时将 findByTitle 之类的查找器表达式转换为适当的 SQL 或 JPA-QL 查询。使用 Micronaut 的无反射编译时 AOP 的非常薄的运行时层只需执行查询并返回结果。

      更新:该项目现已重命名为“Micronaut Data”,here is the new link to the docs

      【讨论】:

      • 密切关注项目,发布后会在此处更新。
      猜你喜欢
      • 1970-01-01
      • 2015-02-13
      • 2018-07-03
      • 2020-02-18
      • 2017-07-17
      • 2021-04-13
      • 1970-01-01
      • 2016-03-26
      • 2018-10-06
      相关资源
      最近更新 更多