How spring data generate sql according to method name?

前端 未结 1 877
终归单人心
终归单人心 2021-01-18 10:10

I know spring data jpa can execute sql by two ways.One is execute sql which is included by @Query, the other is parse method name and generate sql. I clone the source code o

相关标签:
1条回答
  • 2021-01-18 11:00

    Its a multi-step process:

    1. Spring Data JPA generates a proxy class for the repository interface.
    2. The proxy generates a PartTree instance for each repository method using the PartTreeJpaQuery class. The PartTree class is part of the Spring Data Commons module, which is a dependency for the store-specific Spring Data modules (like the Spring Data JPA module).
    3. The PartTree is then passed to a JpaQueryCreator to generate a JPA CriteriaQuery instance.
    4. The CriteriaQuery instance is passed to the underlying JPA provider (Hibernate, OpenJPA, EclipseLink, etc.) which then generates SQL to be executed.
    0 讨论(0)
提交回复
热议问题