Package org.apache.openjpa.jdbc.schema
Class Column
java.lang.Object
org.apache.openjpa.jdbc.schema.Column
- All Implemented Interfaces:
Serializable
Represents a database column. Closely aligned with the column
information available from
DatabaseMetaData
.- Author:
- Abe White, Stephen Kim
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given constraint to this column.void
Copy information from the given column to this one.void
deref()
boolean
equalsColumn
(DBDictionary dict, Column col) Tests compatibility.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
Return the number of decimal digits for the column, if applicable.Return the default value set for this column, if any.Return the default value set for the column, if any.Useful for debugging.boolean
getFlag
(int flag) Flags are used for bookkeeping information.Deprecated.use getFullDBIdentifier()int
getIndex()
Return the column's 0-based index in the owning table.int
The Java type the data in this column is treated as, fromJavaTypes
orJavaSQLTypes
.getName()
Deprecated.use getIdentifier()int
int
getRadix()
int
int
getScale()
Deprecated.int
getSize()
Return the column's size.getTable()
Return the table for the column.Deprecated.Deprecated.use getTargetIdentifier()The name of the field this column joins to, if any.int
getType()
Return the column's SQL type.Deprecated.boolean
boolean
hasConstraint
(Class<? extends Constraint> type) Affirms if this column has any constraint of given type.boolean
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 fromTypes
and size.boolean
Affirms if any foreign key constraint is attached to this column.boolean
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
Return true if this is a NOT NULL column.boolean
Whether the not-null property has been set.boolean
Return true if this column belongs to the table's primary key.boolean
Whether this column stores some form of serialized identity value for a related record.boolean
Sets a marker to indicate that this instance represents a uni-directional one to many relation using the foreign key strategy.boolean
Affirms if any unique constraint is attached to this column.boolean
isXML()
Whether this column is of XML type.void
ref()
void
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.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, fromJavaTypes
orJavaSQLTypes
.void
Deprecated.use setIdentifier(DBIdentifier name)void
setNotNull
(boolean notNull) Set whether this is a NOT NULL column.void
setNullability
(short flag) Sets nullability of this receiver by the given flag.void
setPrecision
(int p) void
setRadix
(int r) void
setRelationId
(boolean rel) Whether this column stores some form of serialized identity value for a related record.void
setScale
(int s) void
void
setSchemaName
(String name) Deprecated.use setSchemaIdentifier(DBIdentifier name)void
setSize
(int size) Set the column's size.void
void
setTableName
(String name) Deprecated.void
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.toString()
Returns the column name.
-
Field Details
-
FLAG_UNINSERTABLE
public static final int FLAG_UNINSERTABLE- See Also:
-
FLAG_UNUPDATABLE
public static final int FLAG_UNUPDATABLE- See Also:
-
FLAG_DIRECT_INSERT
public static final int FLAG_DIRECT_INSERT- See Also:
-
FLAG_DIRECT_UPDATE
public static final int FLAG_DIRECT_UPDATE- See Also:
-
FLAG_FK_INSERT
public static final int FLAG_FK_INSERT- See Also:
-
FLAG_FK_UPDATE
public static final int FLAG_FK_UPDATE- See Also:
-
FLAG_PK_JOIN
public static final int FLAG_PK_JOIN- See Also:
-
-
Constructor Details
-
Column
public Column()Default constructor. -
Column
Deprecated.Constructor.- Parameters:
name
- the name of the columntable
- the column's table
-
Column
-
-
Method Details
-
getTable
Return the table for the column. -
getTableName
Deprecated.The column's table name. -
getTableIdentifier
-
setTableName
Deprecated.The column's table name. You can only call this method on columns whose table object is not set. -
setTableIdentifier
-
resetTableName
Deprecated.Reset the table name with the fully qualified table name which includes the schema name -
resetTableIdentifier
-
getSchemaName
Deprecated.The column's schema name. -
getSchemaIdentifier
-
setSchemaName
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
-
getName
Deprecated.use getIdentifier()Return the column's name. -
getIdentifier
-
setName
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
-
getFullName
Deprecated.use getFullDBIdentifier()Return the column's full name, in the form <table>.<name>. -
getFullDBIdentifier
-
getQualifiedPath
-
getType
public int getType()Return the column's SQL type. This will be one of the type constants defined inTypes
. -
setType
public void setType(int sqlType) Set the column's SQL type. This should be one of the type constants defined inTypes
. -
getTypeName
Deprecated.The database-specific SQL type of this column. -
getTypeIdentifier
-
setTypeName
Deprecated.The database-specific SQL type of this column. -
setTypeIdentifier
-
getJavaType
public int getJavaType()The Java type the data in this column is treated as, fromJavaTypes
orJavaSQLTypes
. -
setJavaType
public void setJavaType(int type) The Java type the data in this column is treated as, fromJavaTypes
orJavaSQLTypes
. -
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. -
getPrecision
public int getPrecision() -
setPrecision
public void setPrecision(int p) -
getScale
public int getScale() -
setScale
public void setScale(int s) -
getRadix
public int getRadix() -
setRadix
public void setRadix(int r) -
getDefaultString
Return the default value set for the column, if any. -
setDefaultString
Set the default value for the column. -
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
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. -
setNullability
public void setNullability(short flag) Sets nullability of this receiver by the given flag.- Parameters:
flag
- one of the JDBC nullability flag namelyDatabaseMetaData.columnNullableUnknown
: not known if the column can be set to null valueDatabaseMetaData.columnNullable
: the column can be set to null valueDatabaseMetaData.columnNoNulls
: the column can not be set to null value
-
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
Deprecated.use getTargetIdentifier()The name of the column this column joins to, if any. Used for mapping. -
getTargetIdentifier
-
setTarget
Deprecated.use setTargetIdentifier(DBIdentifier target)The name of the column this column joins to, if any. Used for mapping. -
setTargetIdentifier
-
getTargetField
The name of the field this column joins to, if any. Used for mapping. -
setTargetField
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. -
getIndex
public int getIndex()Return the column's 0-based index in the owning table. -
setIndex
public 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
Return true if this column is compatible with the given JDBC type fromTypes
and size. -
toString
Returns the column name. -
getDescription
Useful for debugging. -
equalsColumn
Tests compatibility. -
copy
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
-
setVersionStrategy
-
hasComment
public boolean hasComment() -
getComment
-
setComment
-
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
Adds the given constraint to this column. -
removeConstraint
Removes the given constraint from this column. -
hasConstraint
Affirms if this column has any constraint of given type. -
getConstraints
Gets all constrains attached this column. -
getConstraints
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. -
getRefCount
public int getRefCount() -
ref
public void ref() -
deref
public void deref()
-