Package org.apache.openjpa.jdbc.schema
Class Table
java.lang.Object
org.apache.openjpa.jdbc.schema.NameSet
org.apache.openjpa.jdbc.schema.Table
- All Implemented Interfaces:
Serializable
,Comparable<Object>
,SourceTracker
Represents a database table.
- Author:
- Abe White, Stephen Kim
- See Also:
-
Field Summary
Fields inherited from interface org.apache.openjpa.lib.meta.SourceTracker
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Deprecated.addColumn
(DBIdentifier name) addColumn
(DBIdentifier name, DBIdentifier validName) void
addCorrectedColumnName
(String name, boolean validate) Deprecated.void
addCorrectedColumnName
(DBIdentifier name, boolean validate) Add a foreign key to the table.addForeignKey
(String name) Deprecated.addForeignKey
(DBIdentifier name) Deprecated.addIndex
(DBIdentifier name) Set the primary key for the table.addPrimaryKey
(String name) Deprecated.addPrimaryKey
(DBIdentifier name) Deprecated.addUnique
(DBIdentifier name) int
boolean
containsColumn
(String name) Deprecated.boolean
containsColumn
(String name, DBDictionary dict) Deprecated.boolean
containsColumn
(DBIdentifier name) boolean
containsColumn
(DBIdentifier name, DBDictionary dict) boolean
containsColumn
(Column col) Column[]
Return this table's auto-assigned columns.int
Return the column number in the line of the file at which this instance was parsed.Deprecated.getColumn
(DBIdentifier name) getColumn
(DBIdentifier name, boolean create) String[]
Return the list of column names, used only for informative (error) messages.Column[]
Return the table's columns, in alphabetical order.getForeignKey
(String name) Deprecated.getForeignKey
(DBIdentifier name) Return all foreign keys for the table.Deprecated.Deprecated.getIndex
(DBIdentifier name) Index[]
Return the table's indexes.int
Return the line number of the file at which this instance was parsed.getName()
Deprecated.Return the primary key for the table, if any.Column[]
Return this table's relation id columns.Return the domain-meaningful name of the resource that was loaded from this source.Return the schema for the table.Deprecated.Return the file from which this instance was parsed.Return the domain-dependent scope of this instance within its file.int
Return the type of source.Deprecated.getUnique
(DBIdentifier name) Unique[]
Return the table's unique constraints.boolean
importColumn
(Column col) Import a column from another table.Import a foreign key; column names must match columns of this table.importIndex
(Index idx) Import an index; column names must match columns of this table.Import a primary key; column names must match columns of this table.importUnique
(Unique unq) Import a constraint; column names must match columns of this table.boolean
boolean
removeColumn
(Column col) Remove the given column from the table.boolean
Remove the given foreign key from the table.boolean
removeIndex
(Index idx) Remove the given index from the table.boolean
Remove the primary key from this table.boolean
removeUnique
(Unique unq) Remove the given unique constraint from the table.void
void
setColNumber
(int colNum) void
setComment
(String comment) void
setIdentifier
(DBIdentifier name) Set the name of the table.void
setLineNumber
(int lineNum) void
Deprecated.void
void
setSchemaName
(String name) Deprecated.void
toString()
Methods inherited from class org.apache.openjpa.jdbc.schema.NameSet
addName, addName, isNameTaken, isNameTaken, removeName, removeName
-
Constructor Details
-
Table
public Table()Default constructor. -
Table
Deprecated.Constructor.- Parameters:
name
- the table nameschema
- the table schema
-
Table
-
-
Method Details
-
setAssociation
public void setAssociation() -
isAssociation
public boolean isAssociation() -
getSchema
Return the schema for the table. -
getSchemaName
Deprecated.The table's schema name. -
getSchemaIdentifier
-
setSchemaName
Deprecated.The table's schema name. You can only call this method on tables whose schema object is not set. -
setSchemaIdentifier
-
getName
Deprecated.Return the name of the table. -
getIdentifier
-
setName
Deprecated.usesetIdentifier(DBIdentifier)
instead.Set the name of the table. This method can only be called on tables that are not part of a schema. -
setIdentifier
Set the name of the table. This method can only be called on tables which are not part of a schema.- Parameters:
name
- The name of the table.- Throws:
IllegalStateException
- ifgetSchema()
does not return null.
-
getFullName
Deprecated.Return the table name, including schema, using '.' as the catalog separator. -
getQualifiedPath
-
getFullIdentifier
-
getSourceFile
Description copied from interface:SourceTracker
Return the file from which this instance was parsed.- Specified by:
getSourceFile
in interfaceSourceTracker
-
getSourceScope
Description copied from interface:SourceTracker
Return the domain-dependent scope of this instance within its file.- Specified by:
getSourceScope
in interfaceSourceTracker
-
getSourceType
public int getSourceType()Description copied from interface:SourceTracker
Return the type of source.- Specified by:
getSourceType
in interfaceSourceTracker
-
setSource
-
getResourceName
Description copied from interface:SourceTracker
Return the domain-meaningful name of the resource that was loaded from this source. I.e., if we had loaded the source for a Java class, this would return the name of the class.- Specified by:
getResourceName
in interfaceSourceTracker
-
getColumns
Return the table's columns, in alphabetical order. -
getAutoAssignedColumns
Return this table's auto-assigned columns. -
getRelationIdColumns
Return this table's relation id columns. -
getColumnNames
Return the list of column names, used only for informative (error) messages.- Returns:
-
getColumn
Deprecated.Return the column with the given name, or null if none. -
getColumn
-
getColumn
-
containsColumn
Deprecated.Affirms if this table contains the column of the given name without any side-effect. -
containsColumn
-
containsColumn
Deprecated.Affirms if this table contains the column of the given name without any side-effect.- Parameters:
dict
- the current database dictionary or null.- See Also:
-
containsColumn
-
containsColumn
-
addColumn
Deprecated.Add a column to the table. -
addColumn
-
addColumn
Deprecated.Add a column with a shortened (i.e., validated) name to the table -
addColumn
-
addCorrectedColumnName
Deprecated.Add a name to this NameSet -
addCorrectedColumnName
-
removeColumn
Remove the given column from the table.- Returns:
- true if the column was removed, false if not in the table
-
importColumn
Import a column from another table. -
getPrimaryKey
Return the primary key for the table, if any. -
addPrimaryKey
Set the primary key for the table. -
addPrimaryKey
Deprecated.Set the primary key for the table. -
addPrimaryKey
-
removePrimaryKey
public boolean removePrimaryKey()Remove the primary key from this table.- Returns:
- true if there was a pk to remove, false otherwise
-
importPrimaryKey
Import a primary key; column names must match columns of this table. -
getForeignKey
Deprecated.Return the foreign key with the given name. If multiple foreign keys have the name, the first match is returned. -
getForeignKey
-
getForeignKeys
Return all foreign keys for the table. -
addForeignKey
Add a foreign key to the table. -
addForeignKey
Deprecated.Add a foreign key to the table. Duplicate key names are not allowed. -
addForeignKey
-
removeForeignKey
Remove the given foreign key from the table.- Returns:
- true if the key was removed, false if not in the table
-
importForeignKey
Import a foreign key; column names must match columns of this table. -
getIndexes
Return the table's indexes. -
getIndex
Deprecated.Return the index with the given name, or null if none. -
getIndex
-
addIndex
Deprecated.Add an index to the table. -
addIndex
-
removeIndex
Remove the given index from the table.- Returns:
- true if the index was removed, false if not in the table
-
importIndex
Import an index; column names must match columns of this table. -
getUniques
Return the table's unique constraints. -
getUnique
Deprecated.Return the unique constraint with the given name, or null if none. -
getUnique
-
addUnique
Deprecated.Add a unique constraint to the table. -
addUnique
-
removeUnique
Remove the given unique constraint from the table.- Returns:
- true if the constraint was removed, false if not in the table
-
importUnique
Import a constraint; column names must match columns of this table. -
compareTo
- Specified by:
compareTo
in interfaceComparable<Object>
-
toString
-
hasComment
public boolean hasComment() -
getComment
-
setComment
-
getLineNumber
public int getLineNumber()Description copied from interface:SourceTracker
Return the line number of the file at which this instance was parsed.- Specified by:
getLineNumber
in interfaceSourceTracker
-
setLineNumber
public void setLineNumber(int lineNum) -
getColNumber
public int getColNumber()Description copied from interface:SourceTracker
Return the column number in the line of the file at which this instance was parsed.- Specified by:
getColNumber
in interfaceSourceTracker
-
setColNumber
public void setColNumber(int colNum)
-
setIdentifier(DBIdentifier)
instead.