生成 SQL
生成创表 SQL
定义实体类
import com.litongjava.jfinal.plugin.annotation.ATableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ATableName("rumi_rmp_professor_rating_tag")
public class RmpProfessorRatingTag {
private Integer id;
private String tagName;
}
生成创表 SQL
package com.litongjava.open.chat.model;
import org.junit.Test;
import com.litongjava.jfinal.plugin.activerecord.bean.Bean2SqlUtils;
public class RmpProfessorRatingTagTest {
@Test
public void toCreateTableSql() {
String createTableSql = Bean2SqlUtils.toCreateTableSql(RmpProfessorRatingTag.class);
System.out.println(createTableSql);
}
}
output
DROP TABLE IF EXISTS rumi_rmp_professor_rating_tag;
CREATE TABLE rumi_rmp_professor_rating_tag (
id SERIAL PRIMARY KEY,
tag_name VARCHAR,
remark VARCHAR(256),
creator VARCHAR(64) DEFAULT '',
create_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(64) DEFAULT '',
update_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted SMALLINT NOT NULL DEFAULT 0,
tenant_id BIGINT NOT NULL DEFAULT 0
);