org.apache.openjpa.persistence.jdbc
Class PersistenceMappingDefaults

java.lang.Object
  extended by org.apache.openjpa.jdbc.meta.MappingDefaultsImpl
      extended by org.apache.openjpa.persistence.jdbc.PersistenceMappingDefaults
All Implemented Interfaces:
MappingDefaults, Configurable

public class PersistenceMappingDefaults
extends MappingDefaultsImpl

Supplies default mapping information in accordance with JPA spec.

Author:
Steve Kim, Abe White

Field Summary
 
Fields inherited from class org.apache.openjpa.jdbc.meta.MappingDefaultsImpl
dict
 
Constructor Summary
PersistenceMappingDefaults()
           
 
Method Summary
 boolean getPrependFieldNameToJoinTableInverseJoinColumns()
          Whether to prepend the field name to the default name of inverse join columns within join tables.
 Object getStrategy(Discriminator disc, boolean adapt)
          Default discriminator mapping strategy when there is no explicit strategy.
 Object getStrategy(Version vers, boolean adapt)
          Default version mapping strategy when there is no explicit strategy.
 String getTableName(ClassMapping cls, Schema schema)
          Return the default table name for the given class.
 String getTableName(FieldMapping fm, Schema schema)
          Return the default secondary table name for the given field.
 void populateColumns(Version vers, Table table, Column[] cols)
          Fill in default information for the given version columns.
 void populateForeignKeyColumn(ValueMapping vm, String name, Table local, Table foreign, Column col, Object target, boolean inverse, int pos, int cols)
          Fill in default information for the given column used to join a value to its related type.
 void populateJoinColumn(FieldMapping fm, Table local, Table foreign, Column col, Object target, int pos, int cols)
          Fill in default information for the given column used to join a field to its defining class' table.
 void setPrependFieldNameToJoinTableInverseJoinColumns(boolean val)
          Whether to prepend the field name to the default name of inverse join columns within join tables.
 
Methods inherited from class org.apache.openjpa.jdbc.meta.MappingDefaultsImpl
areAllPrimaryKeyColumns, correctName, defaultMissingInfo, endConfiguration, getAddNullIndicator, getBaseClassStrategy, getDataStoreIdColumnName, getDeferConstraints, getDiscriminatorColumnName, getDiscriminatorStrategy, getDiscriminatorValue, getFieldStrategy, getForeignKey, getForeignKeyDeleteAction, getIndex, getIndex, getIndex, getIndexDiscriminator, getIndexLogicalForeignKeys, getIndexName, getIndexVersion, getJoinForeignKey, getJoinForeignKey, getJoinForeignKeyDeleteAction, getJoinIndex, getJoinUnique, getNullIndicatorColumnName, getOrderColumnName, getOrderLists, getPrimaryKeyName, getStoreEnumOrdinal, getStoreUnmappedObjectIdString, getStrategy, getStrategy, getSubclassStrategy, getUnique, getVersionColumnName, getVersionStrategy, installPrimaryKey, isRemoveHungarianNotation, populateColumns, populateColumns, populateDataStoreIdColumns, populateJoinColumn, populateNullIndicatorColumns, populateOrderColumns, removeHungarianNotation, setAddNullIndicator, setBaseClassStrategy, setConfiguration, setDataStoreIdColumnName, setDefaultMissingInfo, setDeferConstraints, setDiscriminatorColumnName, setDiscriminatorStrategy, setFieldStrategies, setFieldStrategy, setForeignKeyDeleteAction, setForeignKeyDeleteAction, setIndexDiscriminator, setIndexLogicalForeignKeys, setIndexVersion, setJoinForeignKeyDeleteAction, setJoinForeignKeyDeleteAction, setNullIndicatorColumnName, setOrderColumnName, setOrderLists, setRemoveHungarianNotation, setStoreEnumOrdinal, setStoreUnmappedObjectIdString, setSubclassStrategy, setUseClassCriteria, setVersionColumnName, setVersionStrategy, startConfiguration, useClassCriteria
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceMappingDefaults

public PersistenceMappingDefaults()
Method Detail

getPrependFieldNameToJoinTableInverseJoinColumns

public boolean getPrependFieldNameToJoinTableInverseJoinColumns()
Whether to prepend the field name to the default name of inverse join columns within join tables. Defaults to true per spec, but set to false for compatibility with older versions of OpenJPA.


setPrependFieldNameToJoinTableInverseJoinColumns

public void setPrependFieldNameToJoinTableInverseJoinColumns(boolean val)
Whether to prepend the field name to the default name of inverse join columns within join tables. Defaults to true per spec, but set to false for compatibility with older versions of OpenJPA.


getStrategy

public Object getStrategy(Version vers,
                          boolean adapt)
Description copied from interface: MappingDefaults
Default version mapping strategy when there is no explicit strategy.

Specified by:
getStrategy in interface MappingDefaults
Overrides:
getStrategy in class MappingDefaultsImpl
Parameters:
vers - the version; will not be mapped, but raw MappingInfo will be available
adapt - whether we can adapt the mapping or schema
Returns:
the strategy alias or a strategy instance, or null

getStrategy

public Object getStrategy(Discriminator disc,
                          boolean adapt)
Description copied from interface: MappingDefaults
Default discriminator mapping strategy when there is no explicit strategy.

Specified by:
getStrategy in interface MappingDefaults
Overrides:
getStrategy in class MappingDefaultsImpl
Parameters:
disc - the discriminator; will not be mapped, but raw MappingInfo will be available
adapt - whether we can adapt the mapping or schema
Returns:
the strategy alias or a strategy instance, or null

getTableName

public String getTableName(ClassMapping cls,
                           Schema schema)
Description copied from interface: MappingDefaults
Return the default table name for the given class. This method is only called for classes mapped to their own table.

Specified by:
getTableName in interface MappingDefaults
Overrides:
getTableName in class MappingDefaultsImpl

getTableName

public String getTableName(FieldMapping fm,
                           Schema schema)
Description copied from interface: MappingDefaults
Return the default secondary table name for the given field. This method is only called for fields whose strategy requires a secondary table.

Specified by:
getTableName in interface MappingDefaults
Overrides:
getTableName in class MappingDefaultsImpl

populateJoinColumn

public void populateJoinColumn(FieldMapping fm,
                               Table local,
                               Table foreign,
                               Column col,
                               Object target,
                               int pos,
                               int cols)
Description copied from interface: MappingDefaults
Fill in default information for the given column used to join a field to its defining class' table. The column will be a clone of the target column, or have its name and Java type set in the case of a constant target.

Specified by:
populateJoinColumn in interface MappingDefaults
Overrides:
populateJoinColumn in class MappingDefaultsImpl
target - the target of this column in the join; may be another column or a constant value
pos - the index of this column in the logical foreign key
cols - the number of columns in the logical foreign key

populateForeignKeyColumn

public void populateForeignKeyColumn(ValueMapping vm,
                                     String name,
                                     Table local,
                                     Table foreign,
                                     Column col,
                                     Object target,
                                     boolean inverse,
                                     int pos,
                                     int cols)
Description copied from interface: MappingDefaults
Fill in default information for the given column used to join a value to its related type. The column will be a clone of the target column, or have its name and Java type set in the case of a constant target.

Specified by:
populateForeignKeyColumn in interface MappingDefaults
Overrides:
populateForeignKeyColumn in class MappingDefaultsImpl
name - base name for value, as decided by mapping
target - the target of this column in the join; may be another column or a constant value
inverse - whether this is an inverse foreign key
pos - the index of this column in the logical foreign key
cols - the number of columns in the logical foreign key

populateColumns

public void populateColumns(Version vers,
                            Table table,
                            Column[] cols)
Description copied from interface: MappingDefaults
Fill in default information for the given version columns. The columns' name and Java type will already be populated with generic defaults that may be replaced.

Specified by:
populateColumns in interface MappingDefaults
Overrides:
populateColumns in class MappingDefaultsImpl


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