org.apache.openjpa.jdbc.schema
Class Column

java.lang.Object
  extended by org.apache.openjpa.jdbc.schema.ReferenceCounter
      extended by org.apache.openjpa.jdbc.schema.Column
All Implemented Interfaces:
Serializable

public class Column
extends ReferenceCounter

Represents a database column. Closely aligned with the column information available from DatabaseMetaData.

Author:
Abe White, Stephen Kim
See Also:
Serialized Form

Field Summary
static int FLAG_DIRECT_INSERT
           
static int FLAG_DIRECT_UPDATE
           
static int FLAG_FK_INSERT
           
static int FLAG_FK_UPDATE
           
static int FLAG_PK_JOIN
           
static int FLAG_UNINSERTABLE
           
static int FLAG_UNUPDATABLE
           
 
Constructor Summary
Column()
          Default constructor.
Column(DBIdentifier name, Table table)
           
Column(String name, Table table)
          Deprecated.  
 
Method Summary
 void addConstraint(Constraint c)
          Adds the given constraint to this column.
 void copy(Column from)
          Copy information from the given column to this one.
 boolean equalsColumn(Column col)
          Tests compatibility.
 String getComment()
           
 Set<Constraint> getConstraints()
          Gets all constrains attached this column.
<T extends Constraint>
Set<T>
getConstraints(Class<T> type)
          Gets all constrains of the given type attached to this column.
 int getDecimalDigits()
          Return the number of decimal digits for the column, if applicable.
 Object getDefault()
          Return the default value set for this column, if any.
 String getDefaultString()
          Return the default value set for the column, if any.
 String getDescription()
          Useful for debugging.
 boolean getFlag(int flag)
          Flags are used for bookkeeping information.
 DBIdentifier getFullDBIdentifier()
           
 String getFullName()
          Deprecated. use getFullDBIdentifier()
 DBIdentifier getIdentifier()
           
 int getIndex()
          Return the column's 0-based index in the owning table.
 int getJavaType()
          The Java type the data in this column is treated as, from JavaTypes or JavaSQLTypes.
 String getName()
          Deprecated. use getIdentifier()
 QualifiedDBIdentifier getQualifiedPath()
           
 DBIdentifier getSchemaIdentifier()
           
 String getSchemaName()
          Deprecated.  
 int getSize()
          Return the column's size.
 Table getTable()
          Return the table for the column.
 DBIdentifier getTableIdentifier()
           
 String getTableName()
          Deprecated.  
 String getTarget()
          Deprecated. use getTargetIdentifier()
 String getTargetField()
          The name of the field this column joins to, if any.
 DBIdentifier getTargetIdentifier()
           
 int getType()
          Return the column's SQL type.
 DBIdentifier getTypeIdentifier()
           
 String getTypeName()
          Deprecated.  
 VersionStrategy getVersionStrategy()
           
 boolean hasComment()
           
 boolean hasConstraint(Class<? extends Constraint> type)
          Affirms if this column has any constraint of given type.
 boolean isAutoAssigned()
          Whether this column is auto-assigned a value on insert.
 boolean isCompatible(int type, String typeName, int size, int decimals)
          Return true if this column is compatible with the given JDBC type from Types and size.
 boolean isForeignKey()
          Affirms if any foreign key constraint is attached to this column.
 boolean isImplicitRelation()
          Affirms if this instance represents an implicit relation.
 boolean isIndex()
          Affirms if any index constraint is attached to this column.
 boolean isLob()
          Whether this column is a LOB.
 boolean isNotNull()
          Return true if this is a NOT NULL column.
 boolean isNotNullExplicit()
          Whether the not-null property has been set.
 boolean isPrimaryKey()
          Return true if this column belongs to the table's primary key.
 boolean isRelationId()
          Whether this column stores some form of serialized identity value for a related record.
 boolean isUni1MFK()
          Sets a marker to indicate that this instance represents a uni-directional one to many relation using the foreign key strategy.
 boolean isUniqueConstraint()
          Affirms if any unique constraint is attached to this column.
 boolean isXML()
          Whether this column is of XML type.
(package private)  void remove()
          Called when the column is removed from its table.
 void removeConstraint(Constraint c)
          Removes the given constraint from this column.
 void resetTableIdentifier(DBIdentifier table)
           
 void resetTableName(String name)
          Deprecated.  
 void setAutoAssigned(boolean autoAssign)
          Whether this column is auto-incrementing.
 void setComment(String comment)
           
 void setDecimalDigits(int digits)
          Set the number of decimal digits for the column.
 void setDefault(Object def)
          Set the default value for the column.
 void setDefaultString(String def)
          Set the default value for the column.
 void setFlag(int flag, boolean on)
          Flags are used for bookkeeping information.
 void setIdentifier(DBIdentifier name)
           
 void setImplicitRelation(boolean flag)
          Sets a marker to imply a logical relation that can not have any physical manifest in the database.
(package private)  void setIndex(int index)
          Set the column's 0-based index in the owning table.
 void setJavaType(int type)
          The Java type the data in this column is treated as, from JavaTypes or JavaSQLTypes.
 void setName(String name)
          Deprecated. use setIdentifier(DBIdentifier name)
 void setNotNull(boolean notNull)
          Set whether this is a NOT NULL column.
(package private)  void setPrimaryKey(boolean pk)
          Set whether this column belongs to the table's primary key.
 void setRelationId(boolean rel)
          Whether this column stores some form of serialized identity value for a related record.
 void setSchemaIdentifier(DBIdentifier name)
           
 void setSchemaName(String name)
          Deprecated. use setSchemaIdentifier(DBIdentifier name)
 void setSize(int size)
          Set the column's size.
 void setTableIdentifier(DBIdentifier name)
           
 void setTableName(String name)
          Deprecated.  
 void setTarget(String target)
          Deprecated. use setTargetIdentifier(DBIdentifier target)
 void setTargetField(String target)
          The name of the field this column joins to, if any.
 void setTargetIdentifier(DBIdentifier target)
           
 void setType(int sqlType)
          Set the column's SQL type.
 void setTypeIdentifier(DBIdentifier typeName)
           
 void setTypeName(String typeName)
          Deprecated.  
 void setUni1MFK(boolean isUni1MFK)
          Affirms if this instance represents a uni-directional one to many relation using the foreign key strategy.
 void setVersionStrategy(VersionStrategy strategy)
           
 void setXML(boolean xml)
          Whether this column is of XML type.
 String toString()
          Returns the column name.
 
Methods inherited from class org.apache.openjpa.jdbc.schema.ReferenceCounter
deref, getRefCount, ref
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FLAG_UNINSERTABLE

public static final int FLAG_UNINSERTABLE
See Also:
Constant Field Values

FLAG_UNUPDATABLE

public static final int FLAG_UNUPDATABLE
See Also:
Constant Field Values

FLAG_DIRECT_INSERT

public static final int FLAG_DIRECT_INSERT
See Also:
Constant Field Values

FLAG_DIRECT_UPDATE

public static final int FLAG_DIRECT_UPDATE
See Also:
Constant Field Values

FLAG_FK_INSERT

public static final int FLAG_FK_INSERT
See Also:
Constant Field Values

FLAG_FK_UPDATE

public static final int FLAG_FK_UPDATE
See Also:
Constant Field Values

FLAG_PK_JOIN

public static final int FLAG_PK_JOIN
See Also:
Constant Field Values
Constructor Detail

Column

public Column()
Default constructor.


Column

public Column(String name,
              Table table)
Deprecated. 

Constructor.

Parameters:
name - the name of the column
table - the column's table

Column

public Column(DBIdentifier name,
              Table table)
Method Detail

remove

void remove()
Called when the column is removed from its table. Removes the column from all table constraints and indexes, then invalidates it.


getTable

public Table getTable()
Return the table for the column.


getTableName

public String getTableName()
Deprecated. 

The column's table name.


getTableIdentifier

public DBIdentifier getTableIdentifier()

setTableName

public void setTableName(String name)
Deprecated. 

The column's table name. You can only call this method on columns whose table object is not set.


setTableIdentifier

public void setTableIdentifier(DBIdentifier name)

resetTableName

public void resetTableName(String name)
Deprecated. 

Reset the table name with the fully qualified table name which includes the schema name


resetTableIdentifier

public void resetTableIdentifier(DBIdentifier table)

getSchemaName

public String getSchemaName()
Deprecated. 

The column's schema name.


getSchemaIdentifier

public DBIdentifier getSchemaIdentifier()

setSchemaName

public void setSchemaName(String name)
Deprecated. use setSchemaIdentifier(DBIdentifier name)

The column's schema name. You can only call this method on columns whose table object is not set.


setSchemaIdentifier

public void setSchemaIdentifier(DBIdentifier name)

getName

public String getName()
Deprecated. use getIdentifier()

Return the column's name.


getIdentifier

public DBIdentifier getIdentifier()

setName

public void setName(String name)
Deprecated. use setIdentifier(DBIdentifier name)

Set the column's name. You can only call this method on columns whose table object is not set.


setIdentifier

public void setIdentifier(DBIdentifier name)

getFullName

public String getFullName()
Deprecated. use getFullDBIdentifier()

Return the column's full name, in the form <table>.<name>.


getFullDBIdentifier

public DBIdentifier getFullDBIdentifier()

getQualifiedPath

public QualifiedDBIdentifier getQualifiedPath()

getType

public int getType()
Return the column's SQL type. This will be one of the type constants defined in Types.


setType

public void setType(int sqlType)
Set the column's SQL type. This should be one of the type constants defined in Types.


getTypeName

public String getTypeName()
Deprecated. 

The database-specific SQL type of this column.


getTypeIdentifier

public DBIdentifier getTypeIdentifier()

setTypeName

public void setTypeName(String typeName)
Deprecated. 

The database-specific SQL type of this column.


setTypeIdentifier

public void setTypeIdentifier(DBIdentifier typeName)

getJavaType

public int getJavaType()
The Java type the data in this column is treated as, from JavaTypes or JavaSQLTypes.


setJavaType

public void setJavaType(int type)
The Java type the data in this column is treated as, from JavaTypes or JavaSQLTypes.


getSize

public int getSize()
Return the column's size.


setSize

public void setSize(int size)
Set the column's size.


getDecimalDigits

public int getDecimalDigits()
Return the number of decimal digits for the column, if applicable.


setDecimalDigits

public void setDecimalDigits(int digits)
Set the number of decimal digits for the column.


getDefaultString

public String getDefaultString()
Return the default value set for the column, if any.


setDefaultString

public void setDefaultString(String def)
Set the default value for the column.


getDefault

public Object getDefault()
Return the default value set for this column, if any. If only a default string has been set, attempts to convert it to the right type based on the Java type set for this column.


setDefault

public void setDefault(Object def)
Set the default value for the column.


isNotNull

public boolean isNotNull()
Return true if this is a NOT NULL column.


setNotNull

public void setNotNull(boolean notNull)
Set whether this is a NOT NULL column.


isNotNullExplicit

public boolean isNotNullExplicit()
Whether the not-null property has been set.


isAutoAssigned

public boolean isAutoAssigned()
Whether this column is auto-assigned a value on insert.


setAutoAssigned

public void setAutoAssigned(boolean autoAssign)
Whether this column is auto-incrementing.


isRelationId

public boolean isRelationId()
Whether this column stores some form of serialized identity value for a related record. This makes the column dependent on the knowing the final identity of the relation before the column value is set.


setRelationId

public void setRelationId(boolean rel)
Whether this column stores some form of serialized identity value for a related record. This makes the column dependent on the knowing the final identity of the relation before the column value is set.


getTarget

public String getTarget()
Deprecated. use getTargetIdentifier()

The name of the column this column joins to, if any. Used for mapping.


getTargetIdentifier

public DBIdentifier getTargetIdentifier()

setTarget

public void setTarget(String target)
Deprecated. use setTargetIdentifier(DBIdentifier target)

The name of the column this column joins to, if any. Used for mapping.


setTargetIdentifier

public void setTargetIdentifier(DBIdentifier target)

getTargetField

public String getTargetField()
The name of the field this column joins to, if any. Used for mapping.


setTargetField

public void setTargetField(String target)
The name of the field this column joins to, if any. Used for mapping.


getFlag

public boolean getFlag(int flag)
Flags are used for bookkeeping information. They are ignored at runtime.


setFlag

public void setFlag(int flag,
                    boolean on)
Flags are used for bookkeeping information. They are ignored at runtime.


isPrimaryKey

public boolean isPrimaryKey()
Return true if this column belongs to the table's primary key.


setPrimaryKey

void setPrimaryKey(boolean pk)
Set whether this column belongs to the table's primary key.


getIndex

public int getIndex()
Return the column's 0-based index in the owning table.


setIndex

void setIndex(int index)
Set the column's 0-based index in the owning table.


isLob

public boolean isLob()
Whether this column is a LOB.


isCompatible

public boolean isCompatible(int type,
                            String typeName,
                            int size,
                            int decimals)
Return true if this column is compatible with the given JDBC type from Types and size.


toString

public String toString()
Returns the column name.

Overrides:
toString in class Object

getDescription

public String getDescription()
Useful for debugging.


equalsColumn

public boolean equalsColumn(Column col)
Tests compatibility.


copy

public void copy(Column from)
Copy information from the given column to this one.


isXML

public boolean isXML()
Whether this column is of XML type.


setXML

public void setXML(boolean xml)
Whether this column is of XML type.


getVersionStrategy

public VersionStrategy getVersionStrategy()

setVersionStrategy

public void setVersionStrategy(VersionStrategy strategy)

hasComment

public boolean hasComment()

getComment

public String getComment()

setComment

public void setComment(String comment)

isImplicitRelation

public boolean isImplicitRelation()
Affirms if this instance represents an implicit relation. For example, a relation expressed as the value of primary key of the related class and not as object reference.

Since:
1.3.0

setImplicitRelation

public void setImplicitRelation(boolean flag)
Sets a marker to imply a logical relation that can not have any physical manifest in the database. For example, a relation expressed as the value of primary key of the related class and not as object reference. Populated from @ForeignKey(implicit=true) annotation. The mutator can only transit from false to true but not vice versa.

Since:
1.3.0

isUni1MFK

public boolean isUni1MFK()
Sets a marker to indicate that this instance represents a uni-directional one to many relation using the foreign key strategy. This non-default mapping of uni-directional one-to-many is supported in JPA 2.0.

Since:
2.0

setUni1MFK

public void setUni1MFK(boolean isUni1MFK)
Affirms if this instance represents a uni-directional one to many relation using the foreign key strategy. This non-default mapping of uni-directional one-to-many is supported in JPA 2.0.

Since:
2.0

addConstraint

public void addConstraint(Constraint c)
Adds the given constraint to this column.


removeConstraint

public void removeConstraint(Constraint c)
Removes the given constraint from this column.


hasConstraint

public boolean hasConstraint(Class<? extends Constraint> type)
Affirms if this column has any constraint of given type.


getConstraints

public Set<Constraint> getConstraints()
Gets all constrains attached this column.


getConstraints

public <T extends Constraint> Set<T> getConstraints(Class<T> type)
Gets all constrains of the given type attached to this column.


isUniqueConstraint

public boolean isUniqueConstraint()
Affirms if any unique constraint is attached to this column.


isIndex

public boolean isIndex()
Affirms if any index constraint is attached to this column.


isForeignKey

public boolean isForeignKey()
Affirms if any foreign key constraint is attached to this column.



Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.