Skip to content

feat: 상품 엔티티 관리용 ItemRepository 인터페이스 추가 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/SpringMall/entity/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Item {

@Id
@Column(name = "item_id")
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.AUTO) // JPA 구현체가 자동으로 생성 전략 결정 (JPA가 사용자 대신 적절한 방식을 선택)
private Long id; // 상품 코드

@Column(nullable = false, length = 50) // not null 설정 , 길이 = 50
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/SpringMall/repository/ItemRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.SpringMall.repository;

import com.SpringMall.entity.Item;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ItemRepository extends JpaRepository<Item, Long> {
/* JpaRepository<T,ID> : 2개의 제네릭 타입을 사용하는데
첫 번째에는 엔티티 타입 클래스
두 번째에는 기본키 타입을 넣어줌

[ JpaRepository 에서 지원하는 메소드 ]
1. <S extends T> save(S entity) : 엔티티 저장 및 수정
2. void delete(T entity) : 엔티티 삭제
3. count() : 엔티티 총 개수 반환
4. Iterable<T> findAll() : 모든 엔티티 조회
*/
}