Skip to content

06) helloSpringDataJpa

choi jae ho edited this page Jun 2, 2021 · 13 revisions

๐Ÿ“‹ Spring Data JPA

4. Query Method

  • id๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ด์„œ ์กฐํšŒํ•˜๊ธฐ ๋ณด๋‹ค๋Š”, ๊ฒ€์ƒ‰์„ ํ†ตํ•ด์„œ ์กฐํšŒํ•  ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค.
  • ๊ทธ ๋ถ€๋ถ„์— ๋Œ€ํ•ด์„œ๋Š” ์ถ”๊ฐ€์ ์œผ๋กœ ๊ตฌํ˜„ํ•ด์•ผ ํ•œ๋‹ค.
  • Spring Data JPA ๋Š” CRUD operations๋ฅผ ์ œ๊ณตํ•œ๋‹ค.
  • method names์— ๋”ฐ๋ผ ๋™์ ์œผ๋กœ ์ฟผ๋ฆฌ๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

ex)

  • User findByEmail(String email), ์ด๋ฉ”์ผ์„ ๊ธฐ์ค€์œผ๋กœ ์กฐํšŒํ•˜๋Š” ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€์ ์œผ๋กœ SQL ์ž๋™์ ์œผ๋กœ ๋งŒ๋“ค์–ด์ง„๋‹ค. ์ด๋ฆ„์„ ๋ฐ”ํƒ•์œผ๋กœ ๋ฉ”์„œ๋“œ๋ฅผ ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ค€๋‹ค๋Š”์ .
  • User findByEmailAndPassword(String email, String password) ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋งŒ๋“ค์–ด์ค€๋‹ค.