Creating a custom query with Spring DATA JPA?

后端 未结 6 1144
旧巷少年郎
旧巷少年郎 2020-12-15 06:07

I\'m working on a project with Spring Data JPA. I have a table in the database as my_query.

I want to create a method which takes a string as a parameter, and then e

6条回答
  •  无人及你
    2020-12-15 06:25

    There is no special support for this. But what you can do is create a custom method with a String parameter and in your implementation get the EntityManager injected and execute it.

    Possibly helpful links:

    https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.custom-implementations

    How to access entity manager with spring boot and spring data

    Note: I would reconsider if what you are trying to do is a good idea because it bleeds implementation details of the repository into the rest of the application.

提交回复
热议问题