- java.lang.Object
-
- org.nkjmlab.sorm4j.util.table_def.TableDefinition
-
public final class TableDefinition 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 classTableDefinition.Builder
-
メソッドの概要
すべてのメソッド staticメソッド インスタンス・メソッド concreteメソッド 修飾子とタイプ メソッド 説明 static TableDefinition.Builderbuilder(Class<?> ormRecordClass)static TableDefinition.Builderbuilder(String tableName)Creates a newTableDefinition.Builderwith the given table name.TableDefinitioncreateIndexesIfNotExists(Orm orm)TableDefinitioncreateTableIfNotExists(Orm orm)TableDefinitiondropTableIfExists(Orm orm)static Optional<Constructor<?>>getCanonicalConstructor(Class<?> recordClass)List<String>getColumnNames()List<String>getCreateIndexIfNotExistsStatements()Gets create index if not exists statements.StringgetCreateTableIfNotExistsStatement()Returns aStringobject representing thisTableDefinition's value.StringgetDropTableIfExistsStatement()Gets drop table if exists statement.StringgetTableName()StringgetTableNameAndColumnDefinitions()Returns aStringobject representing thisTableDefinition's value.static StringtoSqlDataType(Class<?> type)StringtoString()
-
-
-
メソッドの詳細
-
builder
public static TableDefinition.Builder builder(String tableName)
Creates a newTableDefinition.Builderwith the given table name.- 戻り値:
-
builder
public static TableDefinition.Builder builder(Class<?> ormRecordClass)
-
getCanonicalConstructor
public static Optional<Constructor<?>> getCanonicalConstructor(Class<?> recordClass)
-
createIndexesIfNotExists
public TableDefinition createIndexesIfNotExists(Orm orm)
-
createTableIfNotExists
public TableDefinition createTableIfNotExists(Orm orm)
-
dropTableIfExists
public TableDefinition dropTableIfExists(Orm orm)
-
getCreateIndexIfNotExistsStatements
public List<String> getCreateIndexIfNotExistsStatements()
Gets create index if not exists statements. Example.TableDefinition.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 aStringobject representing thisTableDefinition's value.TableDefinition.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()
-
getTableNameAndColumnDefinitions
public String getTableNameAndColumnDefinitions()
Returns aStringobject representing thisTableDefinition's value.TableDefinition.builder("reports").addColumnDefinition("id", VARCHAR, PRIMARY_KEY) .addColumnDefinition("score", INT).build().getTableSchema(); generates "reports(id varchar primary key, score int)"- 戻り値:
-
-