ddl auto strategies

전승원·2020년 12월 21일
0

강의 출처 - 인프런 김영한 강사님
https://www.inflearn.com/course/ORM-JPA-Basic

Options

<property name="hibernate.hbm2ddl.auto" value="create" />

drop table and create

<property name="hibernate.hbm2ddl.auto" value="create-drop" />

create table at the start of the app and drop table at the end of app

<property name="hibernate.hbm2ddl.auto" value="update" />

alter table if there's change

<property name="hibernate.hbm2ddl.auto" value="validate" />

validate if entity and table matches, if not matched, return Exception

Merit: Corresponds to the dialects of db

<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle8iDialect"/>

set Dialect to Oracle (e.g: varchar2, rownum)

Hibernate: 
    
    create table Member (
       id number(19,0) not null,
        age number(10,0) not null,
        name varchar2(255),
        primary key (id)
    )

set Dialect to MySQL (e.g: varchar, limit)

Hibernate: 
    
    create table Member (
       id bigint not null,
        age integer not null,
        name varchar(255),
        primary key (id)
    ) engine=MyISAM

Warning: must not use 'create','create-drop', and 'update' strategies in the actual running service.

profile
No pleasure, No gain

0개의 댓글