Is there with micronaut a way to have the “Spring Data JPA” repository autogenerated from an interface like in spring?

安稳与你 提交于 2019-12-12 16:28:56

问题


Im setting up a new micro service with micronaut and want it to access a database over jpa/hibernate.

Is there an easy way to have the "Spring Data JPA" repositories implementation to be autogenerated from the interface like with spring?

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

Ideally i would the be able to import an ExampleRepository over DI into my service.

EDIT: Micronaut Data is in the process of being released: https://github.com/micronaut-projects/micronaut-data


回答1:


Not currently, although such a feature is planned for the future.




回答2:


In July 2019 Micronaut authors released Predator — short for Precomputed Data Repositories — that is equivalent to Spring Data.

Quoting:

Predator uses Micronaut's ahead-of-time (AoT) compilation APIs to move the entity meta-model into your compiler and translate a finder expression like findByTitle into the appropriate SQL or JPA-QL query at compilation time. A very thin runtime layer that uses Micronaut's reflection-free compilation-time AOP then only has to execute the query and return the results.

UPDATE: The project has now been renamed to "Micronaut Data", here is the new link to the docs



来源:https://stackoverflow.com/questions/54304220/is-there-with-micronaut-a-way-to-have-the-spring-data-jpa-repository-autogener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!