[38μΌμ°¨] κ²μν λ§λ€κΈ°
π2022-08-12π
mysql
local κ³μ ctrl + enter
root κ³μ
μΆμΆκ°
mysql λ²μ νμΈ 8.0.29
Persistence Framework
μ§μμ± νλ μμν¬
μ§μμ± νλ μμν¬(Persistence Framework)λ λ°μ΄ν°μ μ μ₯, μ‘°ν, λ³κ²½, μμ λ₯Ό λ€λ£¨λ ν΄λμ€ λ° μ€μ νμΌλ€μ μ§ν©μ΄λ€. μ§μμ± νλ μμν¬λ₯Ό μ¬μ©νλ©΄ JDBC νλ‘κ·Έλλ°μ 볡μ‘ν¨μ΄λ λ²κ±°λ‘μ μμ΄ κ°λ¨ν μμ λ§μΌλ‘ λ°μ΄ν°λ² μ΄μ€μ μ°λλλ μμ€ν μ λΉ λ₯΄κ² κ°λ°ν μ μμΌλ©° μμ μ μΈ κ΅¬λλ 보μ₯νλ€.
1) SQL mapping
IDνκ³ sql λ§€νν΄μ μ°λ κ±° . λνμ μΌλ‘ MyBatisκ° μλ€. μ°λ¦¬λ μ΄κ²μ μΈ κ²
2) ORM(Object Relation Mapping)
μμ¦ κ°κ΄λ°λ λ°©λ². λ°μ΄ν°λ² μ΄μ€μ νλμ λ μ½λλ₯Ό VO ν΄λμ€ μ²λΌ νλμ κ°μ²΄λ‘ λ€κ³ μ¨λ€. μ¬μ©μλ 쿼리문μ μ°λκ² μλλΌ κ°μ²΄μ setter getterλ₯Ό μ¬μ©νλ€. νλ‘κ·Έλλ¨Έ μ μ₯μμλ 쿼리문μ μ ν μ¬μ©νμ§ μλλ€. ꡬ쑰λ‘λ DBκ° μμΌλ©΄ ORMμ΄ μ‘΄μ¬νκ³ μμ€μ½λμμ newνκ³ κ°μ²΄ λ§λ€κ³ μΆκ° λ©μλλ§ λͺ¨λΈμ μ§μ΄ λ£μ μνμμ μ€κ°μ 쿼리문μΌλ‘ λ°κΎΌλ€. μ§κ° μμμ ν΄μν΄μ κ°μ Έλ€κ° μ€λ€. μ½λμμμλ sqlμ΄ μλ€μ΄κ°λ€. μ΄λ κ² νλ©΄ μ₯μ μ΄ λ°μ΄ν°λ² μ΄μ€λ₯Ό λ°κΎΈλ©΄ ORMμ΄ λ§‘μ λΆλΆλ§ μ€μ νλ©΄ λλ€. JPA java pasistence API .. μ¬μ©λ°©λ²μ μ£Όμ₯. JPA ꡬνν λνμ μΈκ² Hibenateκ° μλ€. λ§μ°¬κ°μ§λ‘ μ€νλ§μ spring - data - jpa κ° μλ€.
https://mvnrepository.com/artifact/org.mybatis/mybatis-spring/2.0.7
https://mvnrepository.com/artifact/org.mybatis/mybatis/3.5.10
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gyuone</groupId>
<artifactId>BoardProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.22</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
</project>