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

DTO | DAO | ORM | SQL Mapper | 영속성(Persistence) | JPA | 도메인과 엔티티 VO #22

Open
kyupid opened this issue Dec 24, 2021 · 4 comments
Assignees
Labels
학습 Extra attention is needed

Comments

@kyupid
Copy link
Owner

kyupid commented Dec 24, 2021

헷갈리는 용어들 정리

@kyupid kyupid added the 학습 Extra attention is needed label Dec 24, 2021
@kyupid kyupid self-assigned this Dec 24, 2021
@kyupid
Copy link
Owner Author

kyupid commented Dec 24, 2021

출처: https://stackoverflow.com/questions/35078383/what-are-the-dao-dto-and-service-layers-in-spring-framework

우선, 이러한 개념은 Platform Agnostic이며 해당 문제에 대해 Spring Framework 또는 기타 프레임워크에만 국한되지 않습니다.

Data Transfer Object

DTO는 프로세스 간에 데이터를 전달하는 개체입니다. 원격 인터페이스로 작업할 때 호출할 때마다 비용이 많이 듭니다. 결과적으로 호출 수를 줄여야 합니다. 해결 방법은 호출에 대한 모든 데이터를 보유할 수 있는 데이터 전송 개체(DTO)를 만드는 것입니다. It needs to be serializable to go across the connection. Usually an assembler is used on the server side to transfer data between the DTO and any domain objects. It's often little more than a bunch of fields and the getters and setters for them.

DTO 옛날에 생각 했던 거

Data Access Object

데이터 액세스 개체(DAO)는 데이터 소스에 대한 모든 액세스를 추상화하고 캡슐화합니다. DAO는 데이터를 획득하고 저장하기 위해 데이터 소스와의 연결을 관리합니다. DAO는 데이터 소스 작업에 필요한 액세스 메커니즘을 구현합니다. 데이터 소스는 RDBMS와 같은 영구 저장소(persistent store)이거나 REST 또는 SOAP를 통해 액세스되는 비즈니스 서비스일 수 있습니다. The DAO abstracts the underlying data access implementation for the Service objects to enable transparent access to the data source. 서비스는 또한 데이터 로드 및 저장 작업을 DAO에 위임합니다.

@kyupid kyupid changed the title DTO DAO Entity VO DTO DAO Entity VO ORM Dec 24, 2021
@kyupid kyupid changed the title DTO DAO Entity VO ORM DTO DAO Entity VO ORM 영속성(Persistence) Dec 24, 2021
@kyupid
Copy link
Owner Author

kyupid commented Dec 24, 2021

출처: https://gmlwjd9405.github.io/2019/02/01/orm.html

영속성 Persistence

  • 데이터를 생성한 프로그램이 종료되더라도 사라지지 않는 데이터의 특성을 말한다.
  • Object Persistence(영구적인 객체) : 메모리 상의 데이터를 파일 시스템, 관계형 테이터베이스 혹은 객체 데이터베이스 등을 활용하여 영구적으로 저장하여 영속성 부여한다.
  • 데이터를 데이터베이스에 저장하는 3가지 방법
    1. JDBC (java에서 사용)
    2. Spring JDBC (Ex. JdbcTemplate)
    3. Persistence Framework (Ex. Hibernate, Mybatis 등)

Persistence Layer

  • 프로그램 아키텍쳐에서 데이터에 영속성을 부여해주는 계층을 말함
  • JDBC를 이용해서 직접구현가능하나 Persistence framework를 이용한 개발이 많이 이루어짐

Persistence Framework

  • JDBC 프로그래밍의 복잡함이나 번거로움없이 간단한 작업만으로 디비와 연동되는 시스템을 빠르게 개발 가능
  • Persistence Framework는 SQL Mapper와 ORM으로 나눌수있다.

ORM

  • 객체와 관계형 디비를 자동으로 매핑(연결) 해줌.

ORM Pros

  • 객체지향적인 코드로 더 직관적이고 비즈니스 로직에 집중 가능
  • ORM을 사용하면 SQL Query가 아닌 직관적인 코드(메소드)로 데이터를 조작해서 객체 모델에 더 집중 가능.
  • 선언문, 할당, 종료 같은 부수적인 코드가 사라짐
  • 객체에 대한 코드를 별도로 작성하기 때문에(Entity, DTO, DAO 등??) 코드의 가독성을 올려준다
  • SQL의 절차적인 접근이아닌 객체지향적 접근

SQL Mapper

  • MyBatis
  • 객체와 관계형 디비의 데이터를 개발자가 작성한 SQL로 매핑
  • 직접 매핑
  • SQL 문법이 다르기때문에 DBMS에 종속적
  • 개발시 SQL 작성해야함

출처: https://gmlwjd9405.github.io/2019/02/01/orm.html

@kyupid kyupid changed the title DTO DAO Entity VO ORM 영속성(Persistence) DTO DAO Entity VO ORM 영속성(Persistence) JPA Dec 24, 2021
@kyupid
Copy link
Owner Author

kyupid commented Dec 24, 2021

출처: https://aonee.tistory.com/59

JPA

  • 자바 ORM 기술에 대한 API 표준 명세
  • 자바에서 제공하는 API
  • 즉 JPA는 ORM사용을 위한 표준 인터페이스를 모두아둔 것

image_222

@kyupid
Copy link
Owner Author

kyupid commented Dec 24, 2021

VO

  • 다른 로직없고 필드들만 담겨있는 객체
  • VO는 식별자가 없고 어떤 필드가 바뀌면 서로 다름

Domain

  • 개발하고자 하는 것을 분석하고, 그 결과로 도출된 객체들을 말함
  • 도메인이라는 것은 자바에서 객체의 어떤 성질을 가진 상태를 부르는 말이 아니라는 것

Entity

  • 디비와 매핑되는 객체
  • 식별자가 있음
  • 상태와 행위를 가지고 있다.
  • 식별자에 따라 Entity끼리 비교하기때문에 VO처럼 필드값이 바뀐다고 해서 다른 객체가 아님

읽을거리
https://multifrontgarden.tistory.com/186

@kyupid kyupid changed the title DTO DAO Entity VO ORM 영속성(Persistence) JPA DTO DAO VO ORM 영속성(Persistence) JPA 도메인과 엔티티 Dec 24, 2021
@kyupid kyupid changed the title DTO DAO VO ORM 영속성(Persistence) JPA 도메인과 엔티티 DTO DAO ORM 영속성(Persistence) JPA 도메인과 엔티티 VO Dec 24, 2021
@kyupid kyupid changed the title DTO DAO ORM 영속성(Persistence) JPA 도메인과 엔티티 VO DTO DAO ORM SQL Mapper 영속성(Persistence) JPA 도메인과 엔티티 VO Dec 24, 2021
@kyupid kyupid changed the title DTO DAO ORM SQL Mapper 영속성(Persistence) JPA 도메인과 엔티티 VO DTO | DAO | ORM | SQL Mapper | 영속성(Persistence) | JPA | 도메인과 엔티티 VO Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
학습 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant