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