问题
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