How does Spring Data JPA work internally

后端 未结 1 1982
-上瘾入骨i
-上瘾入骨i 2020-12-16 18:46

I was going through Spring Data JPA Tutorial. I am confused on how does this framework work internally. Let me state specific scenario

The

相关标签:
1条回答
  • 2020-12-16 19:09

    I recommend to take a look at Query Creation section of the reference guide. It explains the rules pretty clearly.

    For instance when you want to find User by first name and ignore case, you would use method name like findByFirstnameIgnoreCase which would translate into condition like UPPER(x.firstame) = UPPER(?1).

    By default when you have findByProperty method, the match is exact, so if you want to have LIKE functionality you would use method name findByFirstnameLike which would in turn translate into condition where x.firstname like ?1.

    You can combine these keywords, but it can get a little crazy. Personally I prefer using @Query annotation for more complicated queries to avoid super long repository method names.

    0 讨论(0)
提交回复
热议问题