Skip to content
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

ADD : Category Controller/Entity/Repository #2

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

junhee-ko
Copy link
Contributor

No description provided.

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JpaRepository 를 상속받으면 구현체가 org.springframework.data.jpa.repository.support.SimpleJpaRepository 로 만들어져서 이미 @Repository 를 가지게 됩니다. 그래서 여기다가 중복해서 명시하지 않아도 된대요.

@Transactional
public class CategoryController {
@PersistenceContext
EntityManager entityManager;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EntityManager 를 직접 호출해서 사용하는 일은 없을 것 같아요. 바로 서비스가 호출 될 것 같아요.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정답이라고 할 수는 없겠지만 controller layer에서 data persist를 처리하는 것보다 service layer를 하나 더 두는 게 좋은 것 같습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CategoryRepository 를 EntityManager 대신 사용하면 되지 않을까 싶습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants