• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

변경감지 관련 질문드립니다.

21.01.18 16:24 작성 조회수 130

0

안녕하세요 강의 잘 듣고 있습니다.

변경감지와 merge 에 대해서 설명듣고 코드 작성을 해봤는데,

Controller

itemService.updateItem(itemId, bookForm.getName(), bookForm.getPrice(), bookForm.getStockQuantity());

Service

@Transactional
	public void updateItem(Long itemId, String name, int price, int stockQuantity) {
		//변경감지
		Item findItem = itemRepository.findOne(itemId);
		
		findItem.updateItem(name, price, stockQuantity);
	}

Entity

public void updateItem(String name, int price, int stockQuantity) {
		this.name = name;
		this.price = price;
		this.stockQuantity = stockQuantity;
	}

이런 식 으로 코딩을 하는것이 가장 베스트한 방법 일까요 ? ?

답변 1

답변을 작성해보세요.

0

안녕하세요. sjdzn119님

핵심은 변경 감지를 활용하면 됩니다!

감사합니다.