운영장비에서는 절대 create, create-drop, update 사용하지 않을 것!!!
<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="1111"/>
<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.jdbc.batch_size" value="10"/> <!-- 한꺼번에 가능한 쿼리 갯수 지정 -->
<property name="hibernate.hbm2ddl.auto" value="create" /> <!-- 애플리케이션 로딩시점에 데이터베이스 자동 생성 -->
</properties>
Hibernate:
drop table if exists Member CASCADE
Hibernate:
drop table if exists Member2 CASCADE
Hibernate:
create table Member (
id bigint not null,
name varchar(255),
primary key (id)
)
Hibernate:
create table Member2 (
id bigint not null,
age integer not null,
name varchar(255),
primary key (id)
)
@Column(nullable = false, length = 10)
@Table(uniqueConstraints = {@UniqueConstraint( name = "NAME_AGE_UNIQUE",
columnNames = {"NAME", "AGE"} )})