org.hibernate.cfg.reveng
Class DelegatingReverseEngineeringStrategy

java.lang.Object
  extended by org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy
All Implemented Interfaces:
ReverseEngineeringStrategy
Direct Known Subclasses:
TableSelectorStrategy

public class DelegatingReverseEngineeringStrategy
extends Object
implements ReverseEngineeringStrategy


Constructor Summary
DelegatingReverseEngineeringStrategy(ReverseEngineeringStrategy delegate)
           
 
Method Summary
 String classNameToCompositeIdName(String className)
          Given a class name return the name for its composite id if it will have one.
 void close()
          Close any resources this strategy might have used.
 String columnToHibernateTypeName(TableIdentifier table, String columnName, int sqlType, int length, int precision, int scale, boolean nullable, boolean generatedIdentifier)
          Gets the preferred Hibernate type for an SQL type.
 Map columnToMetaAttributes(TableIdentifier identifier, String column)
          Return the list of metaattributes to assign to properties created based on the given column
 String columnToPropertyName(TableIdentifier table, String column)
          Return a property name for a Column.
 void configure(ReverseEngineeringRuntimeInfo runtimeInfo)
          Configure the reverse engineering strategy.
 boolean excludeColumn(TableIdentifier identifier, String columnName)
           
 boolean excludeForeignKeyAsCollection(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns)
          Should this foreignkey be excluded as a oneToMany
 boolean excludeForeignKeyAsManytoOne(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns)
          Should this foreignkey be excluded as a many-to-one
 boolean excludeTable(TableIdentifier ti)
           
 AssociationInfo foreignKeyToAssociationInfo(org.hibernate.mapping.ForeignKey foreignKey)
           
 String foreignKeyToCollectionName(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns, boolean uniqueReference)
          Return a collection role name for a Collection based on the foreignkey.
 String foreignKeyToEntityName(String keyname, TableIdentifier fromTable, List fromColumnNames, TableIdentifier referencedTable, List referencedColumnNames, boolean uniqueReference)
           
 AssociationInfo foreignKeyToInverseAssociationInfo(org.hibernate.mapping.ForeignKey foreignKey)
           
 String foreignKeyToInverseEntityName(String keyname, TableIdentifier fromTable, List fromColumnNames, TableIdentifier referencedTable, List referencedColumnNames, boolean uniqueReference)
          Used to rename the inverse one-to-one properties.
 String foreignKeyToManyToManyName(org.hibernate.mapping.ForeignKey fromKey, TableIdentifier middleTable, org.hibernate.mapping.ForeignKey toKey, boolean uniqueReference)
           
 List getForeignKeys(TableIdentifier referencedTable)
          Gets the user defined foreign keys.
 String getOptimisticLockColumnName(TableIdentifier identifier)
          Return explicit which column name should be used for optimistic lock
 List getPrimaryKeyColumnNames(TableIdentifier identifier)
          If a table does not have any primarykey columns reported, this method is called.
 List getSchemaSelections()
          Return list of SchemaSelctors to be used when asking MetaDataDialect for metadata.
 Properties getTableIdentifierProperties(TableIdentifier identifier)
           
 String getTableIdentifierStrategyName(TableIdentifier tableIdentifier)
           
 boolean isForeignKeyCollectionInverse(String name, TableIdentifier foreignKeyTable, List columns, TableIdentifier foreignKeyReferencedTable, List referencedColumns)
          is the collection inverse or not ?
 boolean isForeignKeyCollectionLazy(String name, TableIdentifier foreignKeyTable, List columns, TableIdentifier foreignKeyReferencedTable, List referencedColumns)
          is the collection lazy or not ?
 boolean isManyToManyTable(org.hibernate.mapping.Table table)
           
 boolean isOneToOne(org.hibernate.mapping.ForeignKey foreignKey)
           
 void setSettings(ReverseEngineeringSettings settings)
          Initialize the settings.
 String tableToClassName(TableIdentifier tableIdentifier)
           
 String tableToCompositeIdName(TableIdentifier identifier)
          Given a table name, return the wanted name for a composite identifier.
 String tableToIdentifierPropertyName(TableIdentifier tableIdentifier)
          Given a table name, return the wanted name for the identifier.
 Map tableToMetaAttributes(TableIdentifier tableIdentifier)
          Return the list of metaattributes to assign to classes created based on the given table
 boolean useColumnForOptimisticLock(TableIdentifier identifier, String column)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingReverseEngineeringStrategy

public DelegatingReverseEngineeringStrategy(ReverseEngineeringStrategy delegate)
Method Detail

getForeignKeys

public List getForeignKeys(TableIdentifier referencedTable)
Description copied from interface: ReverseEngineeringStrategy
Gets the user defined foreign keys.

Specified by:
getForeignKeys in interface ReverseEngineeringStrategy
Parameters:
referencedTable - TODO
Returns:
a list of ForeignKey's

columnToPropertyName

public String columnToPropertyName(TableIdentifier table,
                                   String column)
Description copied from interface: ReverseEngineeringStrategy
Return a property name for a Column.

Specified by:
columnToPropertyName in interface ReverseEngineeringStrategy
column - a columnname
Returns:
a property name

excludeTable

public boolean excludeTable(TableIdentifier ti)
Specified by:
excludeTable in interface ReverseEngineeringStrategy

excludeColumn

public boolean excludeColumn(TableIdentifier identifier,
                             String columnName)
Specified by:
excludeColumn in interface ReverseEngineeringStrategy

foreignKeyToCollectionName

public String foreignKeyToCollectionName(String keyname,
                                         TableIdentifier fromTable,
                                         List fromColumns,
                                         TableIdentifier referencedTable,
                                         List referencedColumns,
                                         boolean uniqueReference)
Description copied from interface: ReverseEngineeringStrategy
Return a collection role name for a Collection based on the foreignkey.

Specified by:
foreignKeyToCollectionName in interface ReverseEngineeringStrategy
fromColumns - list of Column instances on the fromTable. Only col.getName() should be assumed to be correct
referencedColumns - list of Column instances on the referenced Table. Only col.getName() should be assumed to be correct
uniqueReference - true if there is no other references to the same table
Returns:

foreignKeyToEntityName

public String foreignKeyToEntityName(String keyname,
                                     TableIdentifier fromTable,
                                     List fromColumnNames,
                                     TableIdentifier referencedTable,
                                     List referencedColumnNames,
                                     boolean uniqueReference)
Specified by:
foreignKeyToEntityName in interface ReverseEngineeringStrategy
uniqueReference - true if there is no other references to the same table
Returns:

columnToHibernateTypeName

public String columnToHibernateTypeName(TableIdentifier table,
                                        String columnName,
                                        int sqlType,
                                        int length,
                                        int precision,
                                        int scale,
                                        boolean nullable,
                                        boolean generatedIdentifier)
Description copied from interface: ReverseEngineeringStrategy
Gets the preferred Hibernate type for an SQL type.

Specified by:
columnToHibernateTypeName in interface ReverseEngineeringStrategy
Parameters:
table - name of the table, can be null
columnName - name of the column, can be null
sqlType - The sql type.
length - The length of the column.
precision - The number of decimal digits, if applicable.
scale - The scale, if applicable.
nullable - The nullability of the column
generatedIdentifier - true if for a column used in an identifier that is not "assigned", false otherwise.
Returns:
The Preferred hibernate type name.

tableToClassName

public String tableToClassName(TableIdentifier tableIdentifier)
Specified by:
tableToClassName in interface ReverseEngineeringStrategy
Returns:
a fully-qualified class name

getTableIdentifierStrategyName

public String getTableIdentifierStrategyName(TableIdentifier tableIdentifier)
Specified by:
getTableIdentifierStrategyName in interface ReverseEngineeringStrategy
Parameters:
tableIdentifier - the table to look up for
Returns:
the identifier strategy name wanted for a specific table, null if use what the database metadata can tell.

getTableIdentifierProperties

public Properties getTableIdentifierProperties(TableIdentifier identifier)
Specified by:
getTableIdentifierProperties in interface ReverseEngineeringStrategy

getPrimaryKeyColumnNames

public List getPrimaryKeyColumnNames(TableIdentifier identifier)
Description copied from interface: ReverseEngineeringStrategy
If a table does not have any primarykey columns reported, this method is called.

Specified by:
getPrimaryKeyColumnNames in interface ReverseEngineeringStrategy
Returns:
list of strings for each column name that is part of the primary key

classNameToCompositeIdName

public String classNameToCompositeIdName(String className)
Description copied from interface: ReverseEngineeringStrategy
Given a class name return the name for its composite id if it will have one.

Specified by:
classNameToCompositeIdName in interface ReverseEngineeringStrategy
Returns:

configure

public void configure(ReverseEngineeringRuntimeInfo runtimeInfo)
Description copied from interface: ReverseEngineeringStrategy
Configure the reverse engineering strategy. Called before reverse engineering commences. This is mainly for exotic strategies to get access to a connection.

Specified by:
configure in interface ReverseEngineeringStrategy

close

public void close()
Description copied from interface: ReverseEngineeringStrategy
Close any resources this strategy might have used. Called after reverse engineering has been completed.

Specified by:
close in interface ReverseEngineeringStrategy

getOptimisticLockColumnName

public String getOptimisticLockColumnName(TableIdentifier identifier)
Description copied from interface: ReverseEngineeringStrategy
Return explicit which column name should be used for optimistic lock

Specified by:
getOptimisticLockColumnName in interface ReverseEngineeringStrategy

useColumnForOptimisticLock

public boolean useColumnForOptimisticLock(TableIdentifier identifier,
                                          String column)
Specified by:
useColumnForOptimisticLock in interface ReverseEngineeringStrategy

getSchemaSelections

public List getSchemaSelections()
Description copied from interface: ReverseEngineeringStrategy
Return list of SchemaSelctors to be used when asking MetaDataDialect for metadata.

Specified by:
getSchemaSelections in interface ReverseEngineeringStrategy
Returns:
list of SchemaSelection instances

tableToIdentifierPropertyName

public String tableToIdentifierPropertyName(TableIdentifier tableIdentifier)
Description copied from interface: ReverseEngineeringStrategy
Given a table name, return the wanted name for the identifier.

Specified by:
tableToIdentifierPropertyName in interface ReverseEngineeringStrategy
Returns:
name to be used for identification

tableToCompositeIdName

public String tableToCompositeIdName(TableIdentifier identifier)
Description copied from interface: ReverseEngineeringStrategy
Given a table name, return the wanted name for a composite identifier.

Specified by:
tableToCompositeIdName in interface ReverseEngineeringStrategy
Returns:

excludeForeignKeyAsCollection

public boolean excludeForeignKeyAsCollection(String keyname,
                                             TableIdentifier fromTable,
                                             List fromColumns,
                                             TableIdentifier referencedTable,
                                             List referencedColumns)
Description copied from interface: ReverseEngineeringStrategy
Should this foreignkey be excluded as a oneToMany

Specified by:
excludeForeignKeyAsCollection in interface ReverseEngineeringStrategy

excludeForeignKeyAsManytoOne

public boolean excludeForeignKeyAsManytoOne(String keyname,
                                            TableIdentifier fromTable,
                                            List fromColumns,
                                            TableIdentifier referencedTable,
                                            List referencedColumns)
Description copied from interface: ReverseEngineeringStrategy
Should this foreignkey be excluded as a many-to-one

Specified by:
excludeForeignKeyAsManytoOne in interface ReverseEngineeringStrategy

isForeignKeyCollectionInverse

public boolean isForeignKeyCollectionInverse(String name,
                                             TableIdentifier foreignKeyTable,
                                             List columns,
                                             TableIdentifier foreignKeyReferencedTable,
                                             List referencedColumns)
Description copied from interface: ReverseEngineeringStrategy
is the collection inverse or not ?

Specified by:
isForeignKeyCollectionInverse in interface ReverseEngineeringStrategy

isForeignKeyCollectionLazy

public boolean isForeignKeyCollectionLazy(String name,
                                          TableIdentifier foreignKeyTable,
                                          List columns,
                                          TableIdentifier foreignKeyReferencedTable,
                                          List referencedColumns)
Description copied from interface: ReverseEngineeringStrategy
is the collection lazy or not ?

Specified by:
isForeignKeyCollectionLazy in interface ReverseEngineeringStrategy

setSettings

public void setSettings(ReverseEngineeringSettings settings)
Initialize the settings. If subclasses need to use the Settings then it should keep its own reference, but still remember to initialize the delegates settings by calling super.setSettings(settings).

Specified by:
setSettings in interface ReverseEngineeringStrategy
Parameters:
settings - used for this
See Also:
ReverseEngineeringStrategy.setSettings

isManyToManyTable

public boolean isManyToManyTable(org.hibernate.mapping.Table table)
Specified by:
isManyToManyTable in interface ReverseEngineeringStrategy
Returns:
true if this table is considered to be a many-to-many table.

isOneToOne

public boolean isOneToOne(org.hibernate.mapping.ForeignKey foreignKey)
Specified by:
isOneToOne in interface ReverseEngineeringStrategy

foreignKeyToManyToManyName

public String foreignKeyToManyToManyName(org.hibernate.mapping.ForeignKey fromKey,
                                         TableIdentifier middleTable,
                                         org.hibernate.mapping.ForeignKey toKey,
                                         boolean uniqueReference)
Specified by:
foreignKeyToManyToManyName in interface ReverseEngineeringStrategy
uniqueReference - true if there is no other references to the same table
Returns:

tableToMetaAttributes

public Map tableToMetaAttributes(TableIdentifier tableIdentifier)
Description copied from interface: ReverseEngineeringStrategy
Return the list of metaattributes to assign to classes created based on the given table

Specified by:
tableToMetaAttributes in interface ReverseEngineeringStrategy
Returns:
a Map from String to MetaAttribute

columnToMetaAttributes

public Map columnToMetaAttributes(TableIdentifier identifier,
                                  String column)
Description copied from interface: ReverseEngineeringStrategy
Return the list of metaattributes to assign to properties created based on the given column

Specified by:
columnToMetaAttributes in interface ReverseEngineeringStrategy
Returns:
a Map from String to MetaAttribute

foreignKeyToAssociationInfo

public AssociationInfo foreignKeyToAssociationInfo(org.hibernate.mapping.ForeignKey foreignKey)
Specified by:
foreignKeyToAssociationInfo in interface ReverseEngineeringStrategy

foreignKeyToInverseAssociationInfo

public AssociationInfo foreignKeyToInverseAssociationInfo(org.hibernate.mapping.ForeignKey foreignKey)
Specified by:
foreignKeyToInverseAssociationInfo in interface ReverseEngineeringStrategy

foreignKeyToInverseEntityName

public String foreignKeyToInverseEntityName(String keyname,
                                            TableIdentifier fromTable,
                                            List fromColumnNames,
                                            TableIdentifier referencedTable,
                                            List referencedColumnNames,
                                            boolean uniqueReference)
Description copied from interface: ReverseEngineeringStrategy
Used to rename the inverse one-to-one properties.

Specified by:
foreignKeyToInverseEntityName in interface ReverseEngineeringStrategy
uniqueReference - true if there is no other references to the same table
Returns:
null if use defaults or non-empty String with a specific name