Post

Entity ๐Ÿ†š Repository ๐Ÿ†š JPA ๐Ÿ†š DTO

โœ… JPA

JAVA persistence API

๐Ÿ’ก ์—ฌ๊ธฐ์„œ persistence์˜ ๋œป์€?
persistence๋Š” ๊ณ ์ง‘, ์ฆ‰ ์˜์†์„ฑ, ๋”ฐ๋ผ์„œ ํ”„๋กœ๊ทธ๋žจ์ด ์ข…๋ฃŒ๋˜๋”๋ผ๋„ ์‚ฌ๋ผ์ง€์ง€ ์•Š๋Š” ๋ฐ์ดํ„ฐ์˜ ํŠน์„ฑ์„ ์˜๋ฏธํ•œ๋‹ค.
persistence๋Š” ํŒŒ์ผ ์‹œ์Šคํ…œ, RDB ํ˜น์€ ๊ฐ์ฒด ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋“ฑ์„ ํ™œ์šฉํ•˜์—ฌ ๊ตฌํ˜„ํ•œ๋‹ค.
๋ฐ์ดํ„ฐ์— persistenceํ•œ ํŠน์ง•์ด ์—†๋‹ค๋ฉด ๋‹จ์ง€ ๋ฉ”๋ชจ๋ฆฌ์—์„œ๋งŒ ์กด์žฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํ”„๋กœ๊ทธ๋žจ์„ ์ข…๋ฃŒํ•˜๋ฉด ๋ชจ๋‘ ์žƒ์–ด๋ฒ„๋ฆฌ๊ฒŒ ๋  ๊ฒƒ์ด๋‹ค!

โ˜‘๏ธ โ€œpersistenceโ€ in the context of JPA
โ€œpersistenceโ€ refers to the ability of Java objects to be stored, retrieved, and managed in a long-term storage medium, typically a relational database

  • store objects
  • retrieve objects
  • manage object lifecycle
  • mapping java objects to database tables
  • transaction management: data consistency and integrity

โœ… Entity

corresponds to a database table

  • Represent domain object
  • each instance in entity is a row in a table โœ”๏ธ example: userId, name, email, gender

โœ… Repository

design pattern provides abstraction layer for storing and retrieving data

  • provide CRUD along with query methods for interacting with entities
  • custom queries on entities โœ”๏ธ example: save, findById, findAll

โœ… DTO

Data Transfer Object

  • object for data encapsulation and transfer between presentation layer and business layer
This post is licensed under CC BY 4.0 by the author.