com.j256.ormlite.field
Class DatabaseFieldConfig

java.lang.Object
  extended by com.j256.ormlite.field.DatabaseFieldConfig

public class DatabaseFieldConfig
extends Object

Database field configuration information either supplied by a DatabaseField annotation or by direct Java or Spring wiring.

Author:
graywatson

Field Summary
static boolean DEFAULT_CAN_BE_NULL
           
static DataType DEFAULT_DATA_TYPE
           
static boolean DEFAULT_FOREIGN_COLLECTION_ORDER_ASCENDING
           
static Class<? extends DataPersister> DEFAULT_PERSISTER_CLASS
           
 
Constructor Summary
DatabaseFieldConfig()
           
DatabaseFieldConfig(String fieldName)
           
DatabaseFieldConfig(String fieldName, String columnName, DataType dataType, String defaultValue, int width, boolean canBeNull, boolean id, boolean generatedId, String generatedIdSequence, boolean foreign, DatabaseTableConfig<?> foreignTableConfig, boolean useGetSet, Enum<?> unknownEnumValue, boolean throwIfNull, String format, boolean unique, String indexName, String uniqueIndexName, boolean autoRefresh, int maxForeignAutoRefreshLevel, int maxForeignCollectionLevel)
           
 
Method Summary
static Method findGetMethod(Field field, boolean throwExceptions)
          Find and return the appropriate getter method for field.
static Enum<?> findMatchingEnumVal(Field field, String unknownEnumName)
          Internal method that finds the matching enum for a configured field that has the name argument.
static Method findSetMethod(Field field, boolean throwExceptions)
          Find and return the appropriate setter method for field.
static DatabaseFieldConfig fromDatabaseField(DatabaseType databaseType, String tableName, Field field, DatabaseField databaseField)
           
static DatabaseFieldConfig fromField(DatabaseType databaseType, String tableName, Field field)
          Create and return a config converted from a Field that may have one of the following annotations: DatabaseField, ForeignCollectionField, or javax.persistence...
 String getColumnDefinition()
           
 String getColumnName()
           
 DataPersister getDataPersister()
           
 DataType getDataType()
           
 String getDefaultValue()
           
 String getFieldName()
          Return the name of the field in the class.
 String getForeignCollectionColumnName()
           
 String getForeignCollectionForeignFieldName()
           
 int getForeignCollectionMaxEagerLevel()
           
 String getForeignCollectionOrderColumnName()
           
 String getForeignColumnName()
           
 DatabaseTableConfig<?> getForeignTableConfig()
          For a foreign class which does not use the DatabaseField annotations, you need to inject the table configuration.
 String getFormat()
           
 String getGeneratedIdSequence()
           
 String getIndexName(String tableName)
           
 int getMaxForeignAutoRefreshLevel()
           
 Class<? extends DataPersister> getPersisterClass()
           
 String getUniqueIndexName(String tableName)
           
 Enum<?> getUnknownEnumValue()
           
 int getWidth()
           
 boolean isAllowGeneratedIdInsert()
           
 boolean isCanBeNull()
           
 boolean isForeign()
           
 boolean isForeignAutoCreate()
           
 boolean isForeignAutoRefresh()
           
 boolean isForeignCollection()
           
 boolean isForeignCollectionEager()
           
 boolean isForeignCollectionOrderAscending()
           
 boolean isGeneratedId()
           
 boolean isId()
           
 boolean isIndex()
           
 boolean isPersisted()
           
 boolean isReadOnly()
           
 boolean isThrowIfNull()
           
 boolean isUnique()
           
 boolean isUniqueCombo()
           
 boolean isUniqueIndex()
           
 boolean isUseGetSet()
           
 boolean isVersion()
           
 void postProcess()
          Process the settings when we are going to consume them.
 void setAllowGeneratedIdInsert(boolean allowGeneratedIdInsert)
           
 void setCanBeNull(boolean canBeNull)
           
 void setColumnDefinition(String columnDefinition)
           
 void setColumnName(String columnName)
           
 void setDataPersister(DataPersister dataPersister)
          The name is historical.
 void setDataType(DataType dataType)
           
 void setDefaultValue(String defaultValue)
           
 void setFieldName(String fieldName)
           
 void setForeign(boolean foreign)
           
 void setForeignAutoCreate(boolean foreignAutoCreate)
           
 void setForeignAutoRefresh(boolean foreignAutoRefresh)
           
 void setForeignCollection(boolean foreignCollection)
           
 void setForeignCollectionColumnName(String foreignCollectionColumn)
           
 void setForeignCollectionEager(boolean foreignCollectionEager)
           
 void setForeignCollectionForeignColumnName(String foreignCollectionForeignColumnName)
          Deprecated. You should use setForeignCollectionForeignFieldName(String)
 void setForeignCollectionForeignFieldName(String foreignCollectionForeignFieldName)
           
 void setForeignCollectionMaxEagerForeignCollectionLevel(int maxEagerForeignCollectionLevel)
          Deprecated. Should use setForeignCollectionMaxEagerLevel(int)
 void setForeignCollectionMaxEagerLevel(int foreignCollectionMaxEagerLevel)
           
 void setForeignCollectionOrderAscending(boolean foreignCollectionOrderAscending)
           
 void setForeignCollectionOrderColumn(String foreignCollectionOrderColumn)
          Deprecated. You should use setForeignCollectionOrderColumnName(String)
 void setForeignCollectionOrderColumnName(String foreignCollectionOrderColumn)
           
 void setForeignColumnName(String foreignColumnName)
           
 void setForeignTableConfig(DatabaseTableConfig<?> foreignTableConfig)
           
 void setFormat(String format)
           
 void setGeneratedId(boolean generatedId)
           
 void setGeneratedIdSequence(String generatedIdSequence)
           
 void setId(boolean id)
           
 void setIndex(boolean index)
           
 void setIndexName(String indexName)
           
 void setMaxEagerForeignCollectionLevel(int maxEagerForeignCollectionLevel)
          Deprecated. Should use setForeignCollectionMaxEagerLevel(int)
 void setMaxForeignAutoRefreshLevel(int maxForeignLevel)
           
 void setPersisted(boolean persisted)
           
 void setPersisterClass(Class<? extends DataPersister> persisterClass)
           
 void setReadOnly(boolean readOnly)
           
 void setThrowIfNull(boolean throwIfNull)
           
 void setUnique(boolean unique)
           
 void setUniqueCombo(boolean uniqueCombo)
           
 void setUniqueIndex(boolean uniqueIndex)
           
 void setUniqueIndexName(String uniqueIndexName)
           
 void setUnknownEnumValue(Enum<?> unknownEnumValue)
           
 void setUseGetSet(boolean useGetSet)
           
 void setVersion(boolean version)
           
 void setWidth(int width)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PERSISTER_CLASS

public static final Class<? extends DataPersister> DEFAULT_PERSISTER_CLASS

DEFAULT_DATA_TYPE

public static final DataType DEFAULT_DATA_TYPE

DEFAULT_CAN_BE_NULL

public static final boolean DEFAULT_CAN_BE_NULL
See Also:
Constant Field Values

DEFAULT_FOREIGN_COLLECTION_ORDER_ASCENDING

public static final boolean DEFAULT_FOREIGN_COLLECTION_ORDER_ASCENDING
See Also:
Constant Field Values
Constructor Detail

DatabaseFieldConfig

public DatabaseFieldConfig()

DatabaseFieldConfig

public DatabaseFieldConfig(String fieldName)

DatabaseFieldConfig

public DatabaseFieldConfig(String fieldName,
                           String columnName,
                           DataType dataType,
                           String defaultValue,
                           int width,
                           boolean canBeNull,
                           boolean id,
                           boolean generatedId,
                           String generatedIdSequence,
                           boolean foreign,
                           DatabaseTableConfig<?> foreignTableConfig,
                           boolean useGetSet,
                           Enum<?> unknownEnumValue,
                           boolean throwIfNull,
                           String format,
                           boolean unique,
                           String indexName,
                           String uniqueIndexName,
                           boolean autoRefresh,
                           int maxForeignAutoRefreshLevel,
                           int maxForeignCollectionLevel)
Method Detail

getFieldName

public String getFieldName()
Return the name of the field in the class.


setFieldName

public void setFieldName(String fieldName)

getColumnName

public String getColumnName()
See Also:
DatabaseField.columnName()

setColumnName

public void setColumnName(String columnName)

getDataType

public DataType getDataType()
See Also:
DatabaseField.dataType()

setDataType

public void setDataType(DataType dataType)

getDataPersister

public DataPersister getDataPersister()

setDataPersister

public void setDataPersister(DataPersister dataPersister)
The name is historical.


getDefaultValue

public String getDefaultValue()
See Also:
DatabaseField.defaultValue()

setDefaultValue

public void setDefaultValue(String defaultValue)

getWidth

public int getWidth()
See Also:
DatabaseField.width()

setWidth

public void setWidth(int width)

isCanBeNull

public boolean isCanBeNull()
See Also:
DatabaseField.canBeNull()

setCanBeNull

public void setCanBeNull(boolean canBeNull)

isId

public boolean isId()
See Also:
DatabaseField.id()

setId

public void setId(boolean id)

isGeneratedId

public boolean isGeneratedId()
See Also:
DatabaseField.generatedId()

setGeneratedId

public void setGeneratedId(boolean generatedId)

getGeneratedIdSequence

public String getGeneratedIdSequence()
See Also:
DatabaseField.generatedIdSequence()

setGeneratedIdSequence

public void setGeneratedIdSequence(String generatedIdSequence)

isForeign

public boolean isForeign()
See Also:
DatabaseField.foreign()

setForeign

public void setForeign(boolean foreign)

getForeignTableConfig

public DatabaseTableConfig<?> getForeignTableConfig()
For a foreign class which does not use the DatabaseField annotations, you need to inject the table configuration.


setForeignTableConfig

public void setForeignTableConfig(DatabaseTableConfig<?> foreignTableConfig)

isUseGetSet

public boolean isUseGetSet()
See Also:
DatabaseField.useGetSet()

setUseGetSet

public void setUseGetSet(boolean useGetSet)

getUnknownEnumValue

public Enum<?> getUnknownEnumValue()

setUnknownEnumValue

public void setUnknownEnumValue(Enum<?> unknownEnumValue)

isThrowIfNull

public boolean isThrowIfNull()

setThrowIfNull

public void setThrowIfNull(boolean throwIfNull)

isPersisted

public boolean isPersisted()

setPersisted

public void setPersisted(boolean persisted)

getFormat

public String getFormat()

setFormat

public void setFormat(String format)

isUnique

public boolean isUnique()

setUnique

public void setUnique(boolean unique)

isUniqueCombo

public boolean isUniqueCombo()

setUniqueCombo

public void setUniqueCombo(boolean uniqueCombo)

isIndex

public boolean isIndex()

setIndex

public void setIndex(boolean index)

getIndexName

public String getIndexName(String tableName)

setIndexName

public void setIndexName(String indexName)

isUniqueIndex

public boolean isUniqueIndex()

setUniqueIndex

public void setUniqueIndex(boolean uniqueIndex)

getUniqueIndexName

public String getUniqueIndexName(String tableName)

setUniqueIndexName

public void setUniqueIndexName(String uniqueIndexName)

setForeignAutoRefresh

public void setForeignAutoRefresh(boolean foreignAutoRefresh)

isForeignAutoRefresh

public boolean isForeignAutoRefresh()

getMaxForeignAutoRefreshLevel

public int getMaxForeignAutoRefreshLevel()

setMaxForeignAutoRefreshLevel

public void setMaxForeignAutoRefreshLevel(int maxForeignLevel)

isForeignCollection

public boolean isForeignCollection()

setForeignCollection

public void setForeignCollection(boolean foreignCollection)

isForeignCollectionEager

public boolean isForeignCollectionEager()

setForeignCollectionEager

public void setForeignCollectionEager(boolean foreignCollectionEager)

getForeignCollectionMaxEagerLevel

public int getForeignCollectionMaxEagerLevel()

setForeignCollectionMaxEagerLevel

public void setForeignCollectionMaxEagerLevel(int foreignCollectionMaxEagerLevel)

setMaxEagerForeignCollectionLevel

@Deprecated
public void setMaxEagerForeignCollectionLevel(int maxEagerForeignCollectionLevel)
Deprecated. Should use setForeignCollectionMaxEagerLevel(int)


setForeignCollectionMaxEagerForeignCollectionLevel

@Deprecated
public void setForeignCollectionMaxEagerForeignCollectionLevel(int maxEagerForeignCollectionLevel)
Deprecated. Should use setForeignCollectionMaxEagerLevel(int)


getForeignCollectionColumnName

public String getForeignCollectionColumnName()

setForeignCollectionColumnName

public void setForeignCollectionColumnName(String foreignCollectionColumn)

getForeignCollectionOrderColumnName

public String getForeignCollectionOrderColumnName()

setForeignCollectionOrderColumn

@Deprecated
public void setForeignCollectionOrderColumn(String foreignCollectionOrderColumn)
Deprecated. You should use setForeignCollectionOrderColumnName(String)


setForeignCollectionOrderColumnName

public void setForeignCollectionOrderColumnName(String foreignCollectionOrderColumn)

isForeignCollectionOrderAscending

public boolean isForeignCollectionOrderAscending()

setForeignCollectionOrderAscending

public void setForeignCollectionOrderAscending(boolean foreignCollectionOrderAscending)

getForeignCollectionForeignFieldName

public String getForeignCollectionForeignFieldName()

setForeignCollectionForeignColumnName

@Deprecated
public void setForeignCollectionForeignColumnName(String foreignCollectionForeignColumnName)
Deprecated. You should use setForeignCollectionForeignFieldName(String)


setForeignCollectionForeignFieldName

public void setForeignCollectionForeignFieldName(String foreignCollectionForeignFieldName)

getPersisterClass

public Class<? extends DataPersister> getPersisterClass()

setPersisterClass

public void setPersisterClass(Class<? extends DataPersister> persisterClass)

isAllowGeneratedIdInsert

public boolean isAllowGeneratedIdInsert()

setAllowGeneratedIdInsert

public void setAllowGeneratedIdInsert(boolean allowGeneratedIdInsert)

getColumnDefinition

public String getColumnDefinition()

setColumnDefinition

public void setColumnDefinition(String columnDefinition)

isForeignAutoCreate

public boolean isForeignAutoCreate()

setForeignAutoCreate

public void setForeignAutoCreate(boolean foreignAutoCreate)

isVersion

public boolean isVersion()

setVersion

public void setVersion(boolean version)

getForeignColumnName

public String getForeignColumnName()

setForeignColumnName

public void setForeignColumnName(String foreignColumnName)

isReadOnly

public boolean isReadOnly()

setReadOnly

public void setReadOnly(boolean readOnly)

fromField

public static DatabaseFieldConfig fromField(DatabaseType databaseType,
                                            String tableName,
                                            Field field)
                                     throws SQLException
Create and return a config converted from a Field that may have one of the following annotations: DatabaseField, ForeignCollectionField, or javax.persistence...

Throws:
SQLException

findGetMethod

public static Method findGetMethod(Field field,
                                   boolean throwExceptions)
Find and return the appropriate getter method for field.

Returns:
Get method or null if none found.

findSetMethod

public static Method findSetMethod(Field field,
                                   boolean throwExceptions)
Find and return the appropriate setter method for field.

Returns:
Set method or null if none found.

fromDatabaseField

public static DatabaseFieldConfig fromDatabaseField(DatabaseType databaseType,
                                                    String tableName,
                                                    Field field,
                                                    DatabaseField databaseField)

postProcess

public void postProcess()
Process the settings when we are going to consume them.


findMatchingEnumVal

public static Enum<?> findMatchingEnumVal(Field field,
                                          String unknownEnumName)
Internal method that finds the matching enum for a configured field that has the name argument.

Returns:
The matching enum value or null if blank enum name.
Throws:
IllegalArgumentException - If the enum name is not known.


This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.