Version v0.18 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.

Schema DSL

SQLのDDLを組み立てるためのDSL

概要

Schema DSLはマッピング定義から以下のDDLを組み立てます。

  • エンティティに対応するテーブルのCREATE文/DROP文
  • エンティティのIDを生成するシーケンスのCREATE文/DROP文

create

CREATE文を生成するにはcreateを呼び出します。

val query: Query<Unit> = SchemaDsl.create(AddressDef.meta, EmployeeDef.meta)
/*
create table if not exists ADDRESS (ADDRESS_ID integer not null, STREET varchar(500) not null, VERSION integer not null, constraint pk_ADDRESS primary key(ADDRESS_ID));
create table if not exists EMPLOYEE (EMPLOYEE_ID integer not null, EMPLOYEE_NO integer not null, EMPLOYEE_NAME varchar(500) not null, MANAGER_ID integer, HIREDATE date not null, SALARY bigint not null, DEPARTMENT_ID integer not null, ADDRESS_ID integer not null, VERSION integer not null, constraint pk_EMPLOYEE primary key(EMPLOYEE_ID));
*/

drop

DROP文を生成するにはdropを呼び出します。

val query: Query<Unit> = SchemaDsl.drop(AddressDef.meta, EmployeeDef.meta)
/*
drop table if exists ADDRESS;
drop table if exists EMPLOYEE;
*/

dropAll

全てのオブジェクトを削除するためのDROP文を生成するにはdropAllを呼び出します。

val query: Query<Unit> = SchemaDsl.dropAll()
/*
drop all objects;
*/
最終更新 August 15, 2021 : Add heading IDs (5798dd3)