JPA는 특정기능을 제공하는 라이브러리가 아닌 인터페이스이다.
따라서 이를 구현하는 Hibernate, OpenJpa등이 JPA를 구현함.
JPA 의존성을 가져오면, dependecies에 내부적으로 jpa 인터페이스를 가져오는 것을 볼 수 있음.
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="hello">
<properties>
<!-- 필수 속성 -->
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/~/test"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<!-- 옵션 -->
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
<!--<property name="hibernate.hbm2ddl.auto" value="create" />-->
</properties>
</persistence-unit>
</persistence>
- jpa 2.2버전을 쓴다. (persistence version = "2.2"
- persistence-unit name 으로 이름을 지정할 수 있음
- <properties> 안에 driver, user, password, url, dialect가 들어감
- hibernate.dialect => SQL 표준을 지키지 않는 특정 데이터베이스만의 고유한 기능 ( ex : mySql limit, Oracle의 rownum)
=> 해당 property의 value에 사용하는 디비 종류를 입력하여서 해당 디비 sql의 고유한 방언을 사용할 수 있다.
728x90
반응형