λΉ„νŠΈκ΅μœ‘/WEB

[38일차] κ²Œμ‹œνŒ λ§Œλ“€κΈ°

GWLEE 2022. 8. 12. 16:15

πŸ’™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>