パッケージ org.nkjmlab.sorm4j.table
クラス TableSchema
- java.lang.Object
-
- org.nkjmlab.sorm4j.table.TableSchema
-
public class TableSchema extends Object
This class represent a table schema. This class is a utility for users to define tables and indexes. It should be noted that there is no guarantee that this object will match the table definition in the database.- 作成者:
- nkjm
-
-
ネストされたクラスの概要
ネストされたクラス 修飾子とタイプ クラス 説明 static class
TableSchema.Builder
static class
TableSchema.Keyword
-
メソッドの概要
すべてのメソッド staticメソッド インスタンス・メソッド concreteメソッド 修飾子とタイプ メソッド 説明 static TableSchema.Builder
builder()
Creates a newTableSchema.Builder
.static TableSchema.Builder
builder(String tableName)
Creates a newTableSchema.Builder
with the given table name.void
createIndexesIfNotExists(SqlExecutor sqlExecutor)
void
createTableAndIndexesIfNotExists(SqlExecutor sqlExecutor)
void
createTableIfNotExists(SqlExecutor sqlExecutor)
void
dropTableIfExists(SqlExecutor sqlExecutor)
List<String>
getColumnNames()
List<String>
getCreateIndexIfNotExistsStatements()
Gets create index if not exists statements.String
getCreateTableIfNotExistsStatement()
Returns aString
object representing thisTableSchema
's value.String
getDropTableIfExistsStatement()
Gets drop table if exists statement.String
getTableName()
String
getTableSchema()
Returns aString
object representing thisTableSchema
's value.
-
-
-
メソッドの詳細
-
builder
public static TableSchema.Builder builder()
Creates a newTableSchema.Builder
.- 戻り値:
-
builder
public static TableSchema.Builder builder(String tableName)
Creates a newTableSchema.Builder
with the given table name.- 戻り値:
-
createIndexesIfNotExists
public void createIndexesIfNotExists(SqlExecutor sqlExecutor)
-
createTableAndIndexesIfNotExists
public void createTableAndIndexesIfNotExists(SqlExecutor sqlExecutor)
-
createTableIfNotExists
public void createTableIfNotExists(SqlExecutor sqlExecutor)
-
dropTableIfExists
public void dropTableIfExists(SqlExecutor sqlExecutor)
-
getCreateIndexIfNotExistsStatements
public List<String> getCreateIndexIfNotExistsStatements()
Gets create index if not exists statements. Example.TableSchema.builder("reports") .addColumnDefinition("id", VARCHAR, PRIMARY_KEY).addColumnDefinition("score", INT) .addIndexDefinition("score").addIndexDefinition("id", "score").build().getCreateIndexIfNotExistsStatements(); generates "[create index if not exists index_reports_score on reports(score), create index if not exists index_reports_id_score on reports(id, score)]"
- 戻り値:
-
getCreateTableIfNotExistsStatement
public String getCreateTableIfNotExistsStatement()
Returns aString
object representing thisTableSchema
's value.TableSchema.builder("reports").addColumnDefinition("id", VARCHAR, PRIMARY_KEY) .addColumnDefinition("score", INT).build().getTableSchema(); generates "create table if not exists reports(id varchar primary key, score int)"
- 戻り値:
-
getDropTableIfExistsStatement
public String getDropTableIfExistsStatement()
Gets drop table if exists statement.- 戻り値:
-
getTableName
public String getTableName()
-
getTableSchema
public String getTableSchema()
Returns aString
object representing thisTableSchema
's value.TableSchema.builder("reports").addColumnDefinition("id", VARCHAR, PRIMARY_KEY) .addColumnDefinition("score", INT).build().getTableSchema(); generates "reports(id varchar primary key, score int)"
- 戻り値:
-
-