public abstract class MappingInfo extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static interface |
MappingInfo.ForeignKeyDefaults
Supplies default foreign key information.
|
static interface |
MappingInfo.TableDefaults
Supplies default table information.
|
Modifier and Type | Field and Description |
---|---|
static int |
JOIN_FORWARD |
static int |
JOIN_INVERSE |
static int |
JOIN_NONE |
Constructor and Description |
---|
MappingInfo() |
Modifier and Type | Method and Description |
---|---|
void |
assertNoForeignKey(MetaDataContext context,
boolean die)
Assert that the user did not try to place a foreign key on this mapping
or placed an implicit foreign key.
|
void |
assertNoIndex(MetaDataContext context,
boolean die)
Assert that the user did not try to place an index on this mapping.
|
void |
assertNoJoin(MetaDataContext context,
boolean die)
Assert that the user did not try to join.
|
void |
assertNoSchemaComponents(MetaDataContext context,
boolean die)
Assert that the user did not supply any columns, index, unique
constraint, or foreign key for this mapping.
|
void |
assertNoUnique(MetaDataContext context,
boolean die)
Assert that the user did not try to place a unique constraint on this
mapping.
|
void |
assertStrategy(MetaDataContext context,
Object contextStrat,
Object expected,
boolean die)
Assert that this info has the given strategy or no strategy.
|
boolean |
canForeignKey()
The user can mark columns as explicitly not having a foreign key.
|
boolean |
canIndex()
The user can mark columns as explicitly non-indexable.
|
boolean |
canUnique()
The user can mark columns as explicitly not having a unique constraint.
|
void |
clear()
Clear all mapping information.
|
protected void |
clear(boolean canFlags)
Clear mapping information.
|
void |
copy(MappingInfo info)
Copy missing info from the instance to this one.
|
protected Column[] |
createColumns(MetaDataContext context,
String prefix,
Column[] tmplates,
Table table,
boolean adapt)
Retrieve/create columns on the given table by merging the given
template information with any user-provided information.
|
protected ForeignKey |
createForeignKey(MetaDataContext context,
String prefix,
List<Column> given,
MappingInfo.ForeignKeyDefaults def,
Table table,
ClassMapping cls,
ClassMapping rel,
boolean inversable,
boolean adapt)
Retrieve/create a foreign key (possibly logical) on the given columns
by merging the given template information with any user-provided
information.
|
protected Index |
createIndex(MetaDataContext context,
String prefix,
Index tmplate,
Column[] cols,
boolean adapt)
Retrieve/create an index on the given columns by merging the given
template information with any user-provided information.
|
Table |
createTable(MetaDataContext context,
MappingInfo.TableDefaults def,
DBIdentifier schemaName,
DBIdentifier given,
boolean adapt) |
Table |
createTable(MetaDataContext context,
MappingInfo.TableDefaults def,
String schemaName,
String given,
boolean adapt)
Deprecated.
|
protected Unique |
createUnique(MetaDataContext context,
String prefix,
Unique tmplate,
Column[] cols,
boolean adapt)
Retrieve/create a unique constraint on the given columns by merging the
given template information with any user-provided information.
|
ColumnIO |
getColumnIO()
I/O for the columns created by the last call to
createColumns(org.apache.openjpa.meta.MetaDataContext, java.lang.String, org.apache.openjpa.jdbc.schema.Column[], org.apache.openjpa.jdbc.schema.Table, boolean) ,
or for the foreign key created by the last call to
createForeignKey(org.apache.openjpa.meta.MetaDataContext, java.lang.String, java.util.List<org.apache.openjpa.jdbc.schema.Column>, org.apache.openjpa.jdbc.meta.MappingInfo.ForeignKeyDefaults, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.meta.ClassMapping, boolean, boolean) . |
List<Column> |
getColumns()
Raw column data.
|
List<Column> |
getColumns(DBIdentifier tableName)
Gets the columns whose table name matches the given table name.
|
List<Column> |
getColumns(String tableName)
Deprecated.
|
ForeignKey |
getForeignKey()
Raw foreign key information.
|
Index |
getIndex()
Raw index.
|
int |
getJoinDirection()
Direction of the join that the columns of this mapping info form.
|
String |
getStrategy()
Mapping strategy name.
|
Unique |
getUnique()
Raw unique constraint information.
|
boolean |
hasSchemaComponents()
Return true if this info has columns, foreign key information, index
information, etc.
|
boolean |
isImplicitRelation()
Affirms if this instance represents an implicit relation.
|
protected static Column |
mergeColumn(MetaDataContext context,
String prefix,
Column tmplate,
boolean compat,
Column given,
Table table,
boolean adapt,
boolean fill)
Merge the given columns if possible.
|
void |
setCanForeignKey(boolean fkable)
The user can mark columns as explicitly not having a foreign key.
|
void |
setCanIndex(boolean indexable)
The user can mark columns as explicitly non-indexable.
|
void |
setCanUnique(boolean uniquable)
The user can mark columns as explicitly not having a unique constraint.
|
void |
setColumnIO(ColumnIO io)
I/O for the columns created by the last call to
createColumns(org.apache.openjpa.meta.MetaDataContext, java.lang.String, org.apache.openjpa.jdbc.schema.Column[], org.apache.openjpa.jdbc.schema.Table, boolean) ,
or for the foreign key created by the last call to
createForeignKey(org.apache.openjpa.meta.MetaDataContext, java.lang.String, java.util.List<org.apache.openjpa.jdbc.schema.Column>, org.apache.openjpa.jdbc.meta.MappingInfo.ForeignKeyDefaults, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.meta.ClassMapping, boolean, boolean) . |
void |
setColumns(List<Column> cols)
Raw column data.
|
void |
setForeignKey(ForeignKey fk)
Raw foreign key information.
|
void |
setImplicitRelation(boolean flag)
Sets a marker to imply a logical relation that can not have any physical
manifest in the database.
|
void |
setIndex(Index idx)
Raw index.
|
void |
setJoinDirection(int join)
Direction of the join that the columns of this mapping info form.
|
void |
setStrategy(String strategy)
Mapping strategy name.
|
void |
setUnique(Unique unq)
Raw unique constraint information.
|
protected static Column |
syncColumn(MetaDataContext context,
Column col,
int num,
boolean forceJDBCType,
Table colTable,
Table targetTable,
Object target,
boolean inverse)
Create a copy of the given column with the raw mapping information
set correctly, and without settings that match defaults.
|
protected void |
syncColumns(MetaDataContext context,
Column[] cols,
boolean forceJDBCType)
Sets internal column information to match the given mapped columns.
|
protected void |
syncForeignKey(MetaDataContext context,
ForeignKey fk,
Table local,
Table target)
Sets internal constraint and column information to match given mapped
constraint.
|
protected void |
syncIndex(MetaDataContext context,
Index idx)
Sets internal index information to match given mapped index.
|
protected void |
syncUnique(MetaDataContext context,
Unique unq)
Sets internal constraint information to match given mapped constraint.
|
public static final int JOIN_NONE
public static final int JOIN_FORWARD
public static final int JOIN_INVERSE
public String getStrategy()
public void setStrategy(String strategy)
public List<Column> getColumns(String tableName)
public List<Column> getColumns(DBIdentifier tableName)
public Index getIndex()
public void setIndex(Index idx)
public boolean canIndex()
public void setCanIndex(boolean indexable)
public boolean isImplicitRelation()
public void setImplicitRelation(boolean flag)
public ForeignKey getForeignKey()
public void setForeignKey(ForeignKey fk)
public boolean canForeignKey()
public void setCanForeignKey(boolean fkable)
public Unique getUnique()
public void setUnique(Unique unq)
public boolean canUnique()
public void setCanUnique(boolean uniquable)
public ColumnIO getColumnIO()
createColumns(org.apache.openjpa.meta.MetaDataContext, java.lang.String, org.apache.openjpa.jdbc.schema.Column[], org.apache.openjpa.jdbc.schema.Table, boolean)
,
or for the foreign key created by the last call to
createForeignKey(org.apache.openjpa.meta.MetaDataContext, java.lang.String, java.util.List<org.apache.openjpa.jdbc.schema.Column>, org.apache.openjpa.jdbc.meta.MappingInfo.ForeignKeyDefaults, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.meta.ClassMapping, boolean, boolean)
. This is also expected to be set correctly
prior to calls to syncColumns(org.apache.openjpa.meta.MetaDataContext, org.apache.openjpa.jdbc.schema.Column[], boolean)
and syncForeignKey(org.apache.openjpa.meta.MetaDataContext, org.apache.openjpa.jdbc.schema.ForeignKey, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.schema.Table)
.public void setColumnIO(ColumnIO io)
createColumns(org.apache.openjpa.meta.MetaDataContext, java.lang.String, org.apache.openjpa.jdbc.schema.Column[], org.apache.openjpa.jdbc.schema.Table, boolean)
,
or for the foreign key created by the last call to
createForeignKey(org.apache.openjpa.meta.MetaDataContext, java.lang.String, java.util.List<org.apache.openjpa.jdbc.schema.Column>, org.apache.openjpa.jdbc.meta.MappingInfo.ForeignKeyDefaults, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.meta.ClassMapping, boolean, boolean)
. This is also expected to be set correctly
prior to calls to syncColumns(org.apache.openjpa.meta.MetaDataContext, org.apache.openjpa.jdbc.schema.Column[], boolean)
and syncForeignKey(org.apache.openjpa.meta.MetaDataContext, org.apache.openjpa.jdbc.schema.ForeignKey, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.schema.Table)
.public int getJoinDirection()
createForeignKey(org.apache.openjpa.meta.MetaDataContext, java.lang.String, java.util.List<org.apache.openjpa.jdbc.schema.Column>, org.apache.openjpa.jdbc.meta.MappingInfo.ForeignKeyDefaults, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.meta.ClassMapping, boolean, boolean)
. This flag
is also expected to be set correctly prior to calls to
syncForeignKey(org.apache.openjpa.meta.MetaDataContext, org.apache.openjpa.jdbc.schema.ForeignKey, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.schema.Table)
if the join is inversed.public void setJoinDirection(int join)
createForeignKey(org.apache.openjpa.meta.MetaDataContext, java.lang.String, java.util.List<org.apache.openjpa.jdbc.schema.Column>, org.apache.openjpa.jdbc.meta.MappingInfo.ForeignKeyDefaults, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.meta.ClassMapping, boolean, boolean)
. This flag
is also expected to be set correctly prior to calls to
syncForeignKey(org.apache.openjpa.meta.MetaDataContext, org.apache.openjpa.jdbc.schema.ForeignKey, org.apache.openjpa.jdbc.schema.Table, org.apache.openjpa.jdbc.schema.Table)
if the join is inversed.public void clear()
protected void clear(boolean canFlags)
canFlags
- whether to clear information about whether we
can place indexed, foreign keys, etc on this mappingpublic void copy(MappingInfo info)
public boolean hasSchemaComponents()
public void assertNoSchemaComponents(MetaDataContext context, boolean die)
public void assertStrategy(MetaDataContext context, Object contextStrat, Object expected, boolean die)
public void assertNoIndex(MetaDataContext context, boolean die)
public void assertNoUnique(MetaDataContext context, boolean die)
public void assertNoForeignKey(MetaDataContext context, boolean die)
public void assertNoJoin(MetaDataContext context, boolean die)
public Table createTable(MetaDataContext context, MappingInfo.TableDefaults def, String schemaName, String given, boolean adapt)
context
- the mapping that uses the tabledef
- default table name providerschemaName
- default schema if known, or nullgiven
- given table nameadapt
- whether we can alter the schema or mappingspublic Table createTable(MetaDataContext context, MappingInfo.TableDefaults def, DBIdentifier schemaName, DBIdentifier given, boolean adapt)
protected Column[] createColumns(MetaDataContext context, String prefix, Column[] tmplates, Table table, boolean adapt)
context
- the mapping we're retrieving columns forprefix
- localized error message key prefixtmplates
- template columnstable
- the table for the columnsadapt
- whether we can modify the existing mapping or schemaprotected static Column mergeColumn(MetaDataContext context, String prefix, Column tmplate, boolean compat, Column given, Table table, boolean adapt, boolean fill)
context
- the mapping we're retrieving columns forprefix
- localized error message key prefixtmplate
- template for expected column informationcompat
- whether the existing column type must be compatible
with the type of the template columngiven
- the given column information from mapping infotable
- the table for the columnsadapt
- whether we can modify the existing mapping or schemafill
- whether to default missing column informationprotected Index createIndex(MetaDataContext context, String prefix, Index tmplate, Column[] cols, boolean adapt)
context
- the mapping we're retrieving an index forprefix
- localized error message key prefixtmplate
- template for expected index informationcols
- the indexed columnsadapt
- whether we can modify the existing mapping or schemaprotected Unique createUnique(MetaDataContext context, String prefix, Unique tmplate, Column[] cols, boolean adapt)
context
- the mapping we're retrieving a constraint forprefix
- localized error message key prefixtmplate
- template for expected unique informationcols
- the constraint columnsadapt
- whether we can modify the existing mapping or schemaprotected ForeignKey createForeignKey(MetaDataContext context, String prefix, List<Column> given, MappingInfo.ForeignKeyDefaults def, Table table, ClassMapping cls, ClassMapping rel, boolean inversable, boolean adapt)
context
- the mapping we're retrieving a key forprefix
- localized error message key prefixgiven
- the columns given by the userdef
- defaults providertable
- the table for the keycls
- type we're joining fromrel
- target type we're joining toinversable
- whether the foreign key can be inversedadapt
- whether we can modify the existing mapping or schemaprotected void syncColumns(MetaDataContext context, Column[] cols, boolean forceJDBCType)
forceJDBCType
- whether to force the jdbc-type of the columns
to be set, even when it matches the default for the columns' java typeprotected void syncIndex(MetaDataContext context, Index idx)
protected void syncUnique(MetaDataContext context, Unique unq)
protected void syncForeignKey(MetaDataContext context, ForeignKey fk, Table local, Table target)
local
- default local tabletarget
- default target tableprotected static Column syncColumn(MetaDataContext context, Column col, int num, boolean forceJDBCType, Table colTable, Table targetTable, Object target, boolean inverse)
num
- the number of columns for this mappingforceJDBCType
- whether the jdbc-type of the created column
should be set, even if it matches the default
for the given column's java typecolTable
- expected table for the columntargetTable
- expected target table for join columntarget
- target column or object for join column; for a
constant null target, use NULL
inverse
- whether join column is for inverse joinCopyright © 2006–2017 Apache Software Foundation. All rights reserved.