com.j256.ormlite.table
Class DatabaseTableConfig<T>

java.lang.Object
  extended by com.j256.ormlite.table.DatabaseTableConfig<T>

public class DatabaseTableConfig<T>
extends Object

Database table configuration information either supplied by Spring or direct Java wiring or from a DatabaseTable annotation.

Author:
graywatson

Constructor Summary
DatabaseTableConfig()
           
DatabaseTableConfig(Class<T> dataClass, List<DatabaseFieldConfig> fieldConfigs)
          Setup a table config associated with the dataClass and field configurations.
DatabaseTableConfig(Class<T> dataClass, String tableName, List<DatabaseFieldConfig> fieldConfigs)
          Setup a table config associated with the dataClass, table-name, and field configurations.
 
Method Summary
 void extractFieldTypes(ConnectionSource connectionSource)
          Extract the field types from the fieldConfigs if they have not already been configured.
static
<T> FieldType
extractIdFieldType(ConnectionSource connectionSource, Class<T> clazz, String tableName)
          Find and return the field-type of the id field in this class.
static
<T> String
extractTableName(Class<T> clazz)
          Extract and return the table name for a class.
static
<T> Constructor<T>
findNoArgConstructor(Class<T> dataClass)
          Locate the no arg constructor for the class.
static
<T> DatabaseTableConfig<T>
fromClass(ConnectionSource connectionSource, Class<T> clazz)
          Extract the DatabaseTableConfig for a particular class by looking for class and field annotations.
 Constructor<T> getConstructor()
          Return the constructor for this class.
 Class<T> getDataClass()
           
 List<DatabaseFieldConfig> getFieldConfigs()
           
 FieldType[] getFieldTypes(DatabaseType databaseType)
          Return the field types associated with this configuration.
 String getTableName()
           
 void initialize()
          Initialize the class if this is being called with Spring.
 void setConstructor(Constructor<T> constructor)
           
 void setDataClass(Class<T> dataClass)
           
 void setFieldConfigs(List<DatabaseFieldConfig> fieldConfigs)
           
 void setTableName(String tableName)
          Set the table name which is turned into lowercase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseTableConfig

public DatabaseTableConfig()

DatabaseTableConfig

public DatabaseTableConfig(Class<T> dataClass,
                           List<DatabaseFieldConfig> fieldConfigs)
Setup a table config associated with the dataClass and field configurations. The table-name will be extracted from the dataClass.


DatabaseTableConfig

public DatabaseTableConfig(Class<T> dataClass,
                           String tableName,
                           List<DatabaseFieldConfig> fieldConfigs)
Setup a table config associated with the dataClass, table-name, and field configurations.

Method Detail

initialize

public void initialize()
Initialize the class if this is being called with Spring.


getDataClass

public Class<T> getDataClass()

setDataClass

public void setDataClass(Class<T> dataClass)

getTableName

public String getTableName()

setTableName

public void setTableName(String tableName)
Set the table name which is turned into lowercase. If not specified then the name is gotten from the class name.


setFieldConfigs

public void setFieldConfigs(List<DatabaseFieldConfig> fieldConfigs)

extractFieldTypes

public void extractFieldTypes(ConnectionSource connectionSource)
                       throws SQLException
Extract the field types from the fieldConfigs if they have not already been configured.

Throws:
SQLException

getFieldTypes

public FieldType[] getFieldTypes(DatabaseType databaseType)
                          throws SQLException
Return the field types associated with this configuration.

Throws:
SQLException

getFieldConfigs

public List<DatabaseFieldConfig> getFieldConfigs()

getConstructor

public Constructor<T> getConstructor()
Return the constructor for this class. If not constructor has been set on the class then it will be found on the class through reflection.


setConstructor

public void setConstructor(Constructor<T> constructor)

fromClass

public static <T> DatabaseTableConfig<T> fromClass(ConnectionSource connectionSource,
                                                   Class<T> clazz)
                                        throws SQLException
Extract the DatabaseTableConfig for a particular class by looking for class and field annotations. This is used by internal classes to configure a class.

Throws:
SQLException

extractTableName

public static <T> String extractTableName(Class<T> clazz)
Extract and return the table name for a class.


extractIdFieldType

public static <T> FieldType extractIdFieldType(ConnectionSource connectionSource,
                                               Class<T> clazz,
                                               String tableName)
                                    throws SQLException
Find and return the field-type of the id field in this class.

Throws:
SQLException

findNoArgConstructor

public static <T> Constructor<T> findNoArgConstructor(Class<T> dataClass)
Locate the no arg constructor for the class.



Copyright © 2011. All Rights Reserved.