public class TableUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> int |
clearTable(ConnectionSource connectionSource,
Class<T> dataClass)
Clear all data out of the table.
|
static <T> int |
clearTable(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig)
Clear all data out of the table.
|
static <T> int |
createTable(ConnectionSource connectionSource,
Class<T> dataClass)
Issue the database statements to create the table associated with a class.
|
static <T> int |
createTable(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig)
Issue the database statements to create the table associated with a table configuration.
|
static int |
createTable(Dao<?,?> dao)
Issue the database statements to create the table associated with a table configuration.
|
static <T> int |
createTableIfNotExists(ConnectionSource connectionSource,
Class<T> dataClass)
Create a table if it does not already exist.
|
static <T> int |
createTableIfNotExists(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig)
Create a table if it does not already exist.
|
static <T,ID> int |
dropTable(ConnectionSource connectionSource,
Class<T> dataClass,
boolean ignoreErrors)
Issue the database statements to drop the table associated with a class.
|
static <T,ID> int |
dropTable(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig,
boolean ignoreErrors)
Issue the database statements to drop the table associated with a table configuration.
|
static <T,ID> int |
dropTable(Dao<T,ID> dao,
boolean ignoreErrors)
Issue the database statements to drop the table associated with a dao.
|
static <T,ID> List<String> |
getCreateTableStatements(ConnectionSource connectionSource,
Class<T> dataClass)
Return an list of SQL statements that need to be run to create a table.
|
static <T,ID> List<String> |
getCreateTableStatements(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig)
Return an list of SQL statements that need to be run to create a table.
|
static <T> List<String> |
getCreateTableStatements(DatabaseType databaseType,
Class<T> dataClass)
Deprecated.
|
public static <T> int createTable(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException
connectionSource
- Associated connection source.dataClass
- The class for which a table will be created.SQLException
public static int createTable(Dao<?,?> dao) throws SQLException
dao
- Associated dao.SQLException
public static <T> int createTableIfNotExists(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException
SQLException
public static <T> int createTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig) throws SQLException
connectionSource
- connectionSource Associated connection source.tableConfig
- Hand or spring wired table configuration. If null then the class must have DatabaseField
annotations.SQLException
public static <T> int createTableIfNotExists(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig) throws SQLException
SQLException
public static <T,ID> List<String> getCreateTableStatements(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException
createTable(com.j256.ormlite.support.ConnectionSource, java.lang.Class<T>)
.connectionSource
- Our connect source which is used to get the database type, not to apply the creates.dataClass
- Class of the entity to create statements that will create the table.SQLException
public static <T,ID> List<String> getCreateTableStatements(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig) throws SQLException
createTable(com.j256.ormlite.support.ConnectionSource, java.lang.Class<T>)
.connectionSource
- Our connect source which is used to get the database type, not to apply the creates.tableConfig
- Hand or spring wired table configuration. If null then the class must have DatabaseField
annotations.SQLException
@Deprecated public static <T> List<String> getCreateTableStatements(DatabaseType databaseType, Class<T> dataClass) throws SQLException
getCreateTableStatements(ConnectionSource, Class)
.SQLException
public static <T,ID> int dropTable(ConnectionSource connectionSource, Class<T> dataClass, boolean ignoreErrors) throws SQLException
WARNING: This is [obviously] very destructive and is unrecoverable.
connectionSource
- Associated connection source.dataClass
- The class for which a table will be dropped.ignoreErrors
- If set to true then try each statement regardless of SQLException
thrown previously.SQLException
public static <T,ID> int dropTable(Dao<T,ID> dao, boolean ignoreErrors) throws SQLException
dao
- Associated dao.SQLException
public static <T,ID> int dropTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig, boolean ignoreErrors) throws SQLException
WARNING: This is [obviously] very destructive and is unrecoverable.
connectionSource
- Associated connection source.tableConfig
- Hand or spring wired table configuration. If null then the class must have DatabaseField
annotations.ignoreErrors
- If set to true then try each statement regardless of SQLException
thrown previously.SQLException
public static <T> int clearTable(ConnectionSource connectionSource, Class<T> dataClass) throws SQLException
WARNING: This is [obviously] very destructive and is unrecoverable.
SQLException
public static <T> int clearTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig) throws SQLException
WARNING: This is [obviously] very destructive and is unrecoverable.
SQLException
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.