JPA(Java Persistent API)λ μ€νλ§ νλ μμν¬μμ JPAλ₯Ό νΈλ¦¬νκ² μ¬μ©ν μ μλλ‘ μ§μνλ νλ‘μ νΈ
org.springframework.date.jpa.repository.JpaRepository
μΈν°νμ΄μ€μ count
, delete
, deleteAll
, deleteAll
, deleteById
, existsById
, findById
, save
λ±μ΄ ꡬνλμ΄ μλ€public interface SpringDataJpaItemRepository extends JpaRepository<Item,Long> {
List<Item> findByItemNameLike(String itemName);
List<Item> findByPriceLessThanEqual(Integer price);
//쿼리 λ©μλ (μλ λ©μλμ κ°μ κΈ°λ₯ μν)
List<Item> findByItemNameLikeAndPriceLessThanEqual(String itemName, Integer price);
//쿼리 μ§μ μ€ν
@Query("select i from Item i where i.itemName like :itemName and i.price <= :price")
List<Item> findItems(@Param("itemName") String itemName, @Param("price") Integer price);
}
β μ΄λ κ² JpaRepository μΈν°νμ΄μ€λ§ μμλ°μλ Spring Data JPAκ° νλ‘μ κΈ°μ μ μ¬μ©ν΄μ ꡬν ν΄λμ€λ₯Ό λ§λ€κ³ μ€νλ§ λΉμΌλ‘ λ±λ‘ν΄μ£ΌκΈ° λλ¬Έμ κ°λ°μλ ꡬν ν΄λμ€ μμ΄ μΈν°νμ΄μ€λ§ λ§λ€λ©΄ κΈ°λ³Έ CRUD κΈ°λ₯μ μ¬μ©ν μ μλ€
//쿼리 λ©μλ
List<Item> findByItemNameLikeAndPriceLessThanEqual(String itemName, Integer price);
β μ€νλ§ λ°μ΄ν° JPAλ μΈν°νμ΄μ€μ λ©μλ μ΄λ¦λ§ μ μ΄λλ©΄, λ©μλ μ΄λ¦μ λΆμν΄μ 쿼리λ₯Ό μλμΌλ‘ λ§λ€κ³ μ€νν΄μ£Όλ κΈ°λ₯μ μ 곡νλ€
//쿼리 μ§μ μ€ν
@Query("select i from Item i where i.itemName like :itemName and i.price <= :price")
List<Item> findItems(@Param("itemName") String itemName, @Param("price") Integer price);
β 쿼리 λ©μλ κΈ°λ₯μ μ¬μ©νμ§ μκ³ μ§μ JPQLμ μ¬μ©νκ³ μΆμ λλ @Query
μ μ§μ JPQLμ μμ±νλ©΄ λλ€
β @Query
λ₯Ό μ¬μ©νλ©΄ λ©μλ μ΄λ¦μΌλ‘ μ€ννλ κ·μΉμ΄ 무μλλ€
JPQL(Java Persistence Query Language)λ μν°ν° κ°μ²΄λ₯Ό λμμΌλ‘ νλ 쿼리 μΈμ΄
//λμ΄κ° 18μ΄ μ΄μμΈ μ μ λ₯Ό μ‘°ν
select u from User as u where u.age > 18
//쿼리 μ§μ μ€ν
@Query("select i from Item i where i.itemName like :itemName and i.price <= :price")
List<Item> findItems(@Param("itemName") String itemName, @Param("price") Integer price);
μννΈμ¨μ΄ κ°λ°μμ μ¬μ©λλ λ¬Έμλ‘ APIμ μ΄λ¦, νλΌλ―Έν°(λ§€κ°λ³μ), μΈν°νμ΄μ€, λ°ν κ° λ±μ ꡬ문, μΈμ¦ λ° μΈκ°λ°©λ²(λμλ°©μ), λ°μ΄ν° μ λ¬ νμ λ± APIλ₯Ό μ ννκ² νΈμΆνκ³ κ·Έ κ²°κ³Όλ₯Ό λͺ νν ν΄μνλλ° νμν μ 보λ€μ μΌκ΄λ νμμΌλ‘ κΈ°μ ν κ²
βΎ APIμ μ€κ³, κ°λ° λ° λ¬Έμν κ³Όμ μμ μ©μ΄
βΎ μλ‘ λ€λ₯Έ ν΄λΌμ°λ μλΉμ€ κ°μ API μ°λμμ νμν¨
ERD(Entity Relationship Diagram)λ 'EntityΒ κ°μ²΄'μ 'RelationshipΒ κ΄κ³'λ₯Ό μ€μ μ μΌλ‘ νμνλΒ λ°μ΄ν°λ² μ΄μ€ ꡬ쑰λ₯Ό ν λμ μμ보기 μν΄ κ·Έλ €λλ λ€μ΄μ΄κ·Έλ¨
type: Subject
body
footer
β κΈ°λ³Έμ μΈ μ»€λ° λ©μμ§ κ΅¬μ‘°λ μ λͺ©, λ³Έλ¬Έ, κΌ¬λ¦¬λ§ μΈκ°μ§ ννΈλ‘ λλκ³ , κ° ννΈλ λΉμ€μ λμ΄ κ΅¬λΆνλ€
feat
: μλ‘μ΄ κΈ°λ₯
fix
: λ²κ·Έ ν΄κ²°
docs
: λ¬Έμ λ³κ²½
style
: formatting, λμΉ μΈλ―Έμ½λ‘ λ±... μ½λμ λ³κ²½μ μμ
refactor
: μ½λ 리ν©ν λ§
test
: ν
μ€νΈ μ½λ μΆκ° νΉμ ν
μ€νΈ μ½λ 리ν©ν λ§. μ½λμ λ³κ²½μ μμ
chore
: ν¨ν€μ§ λ§€λμ ꡬμ±, λΉλ μμ
μ
λ°μ΄νΈ. μ½λμ λ³κ²½μ μμ
Feat: κ΄μ¬μ§μ μλ¦Ό ON/OFF κΈ°λ₯ μΆκ°(#123)
μꡰꡬμ μλ¦Όμ κ°κ° ON/OFF ν μ μλλ‘ κΈ°λ₯μ μΆκ°ν¨
- opnion0055: κ΅¬λΆ μ½λ
ν΄κ²°: close #123
com
γ΄ example
γ΄ sju
γ΄ config
γ΄ controller
γ΄ domain
γ΄ repository
γ΄ service
γ΄ security
γ΄ exception
β μ€νλ§ μΉ κ³μΈ΅μ λν ν΄λμ€ νΉμ λλ ν°λ¦¬λ€μ κΈ°λ°μΌλ‘ ν¨ν€μ§νλ λ°©λ²
β κ³μΈ΅ν ꡬ쑰λ μ 체μ μΈ κ΅¬μ‘°λ₯Ό λΉ λ₯΄κ² νμ
ν μ μλ μ₯μ μ΄ μμ§λ§, κ°κ°μ ν¨ν€μ§ λλ ν°λ¦¬μ ν΄λμ€λ€μ΄ λ무 λ§μ΄ λͺ¨μ΄κ² λλ€λ λ¨μ μ΄ μ‘΄μ¬νλ€
com
γ΄ example
γ΄ vivid
γ΄ domain
| γ΄ user
| | γ΄ api
| | γ΄ application
| | γ΄ dao
| | γ΄ domain
| | γ΄ dto
| | γ΄ exception
| γ΄ video
| | γ΄ api
| | γ΄ application
| | γ΄ dao
| | γ΄ domain
| | γ΄ dto
| | γ΄ exception
| ...
γ΄ global
γ΄ auth
γ΄ common
γ΄ config
γ΄ error
γ΄ infra
γ΄ util
β κ°κ°μ λλ©μΈ λ³λ‘ ν¨ν€μ§ λΆλ¦¬κ° κ°λ₯νμ¬ κ΄λ¦¬μ μμ΄μ κ³μΈ΅ν λ°©μλ³΄λ€ μ§κ΄μ μ΄λ©°, κ°κ°μ λλ©μΈλ€μ μλ‘λ₯Ό μμ‘΄νλ μ½λκ° μλλ‘ μ€κ³νκΈ° μ ν©ν΄μ μ½λμ μ¬νμ©μ±μ΄ ν₯μλλ€
PR(Pull Request)μ μ격 μ μ₯μμ pushνμ¬ μλ‘μ΄ μ¬νμ΄ μ μ₯λμμ λ, νλ‘μ νΈ κ΄λ¦¬μμκ² μλ‘μ΄ μ½λ λ³κ²½μ¬νμ μλ¦¬κ³ μλ³Έ μμ€ μ½λμ λ³ν©μ μμ²νλ κ²μ΄λ€. μ½λλ₯Ό λ³ν©νλ κ³Όμ μμ μλ‘ μ½λλ νμΈν μ μκ³ μ΄λ€ λΆλΆμ μμ νλμ§λ νμΈν μ μλλ‘ Pull requestλ₯Ό μ§ννλ€.
π ERD μμ± λ°©λ²
π μ»€λ° μ»¨λ²€μ
μμ±νκΈ°
π ν¨ν€μ§ ꡬ쑰 μ€μ