org.hibernate.cfg.reveng
Class DefaultReverseEngineeringStrategy

java.lang.Object
  extended by org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy
All Implemented Interfaces:
ReverseEngineeringStrategy

public class DefaultReverseEngineeringStrategy
extends Object
implements ReverseEngineeringStrategy


Constructor Summary
DefaultReverseEngineeringStrategy()
           
 
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 columnName)
          Return a property name for a Column.
 void configure(ReverseEngineeringRuntimeInfo rti)
          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)
           
 String foreignKeyToCollectionName(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns, boolean uniqueReference)
          Does some crude english pluralization TODO: are the from/to names correct ?
 String foreignKeyToEntityName(String keyname, TableIdentifier fromTable, List fromColumnNames, TableIdentifier referencedTable, List referencedColumnNames, boolean uniqueReference)
           
 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.
protected  ReverseEngineeringStrategy getRoot()
           
protected  ReverseEngineeringRuntimeInfo getRuntimeInfo()
           
 List getSchemaSelections()
          Return list of SchemaSelctors to be used when asking MetaDataDialect for metadata.
 Properties getTableIdentifierProperties(TableIdentifier identifier)
           
 String getTableIdentifierStrategyName(TableIdentifier identifier)
           
 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)
           
protected  String pluralize(String singular)
           
 void setSettings(ReverseEngineeringSettings settings)
          Generic method used to initialize the reverse engineering strategy.
 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
protected  String toUpperCamelCase(String s)
           
 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

DefaultReverseEngineeringStrategy

public DefaultReverseEngineeringStrategy()
Method Detail

columnToPropertyName

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

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

toUpperCamelCase

protected String toUpperCamelCase(String s)

foreignKeyToCollectionName

public String foreignKeyToCollectionName(String keyname,
                                         TableIdentifier fromTable,
                                         List fromColumns,
                                         TableIdentifier referencedTable,
                                         List referencedColumns,
                                         boolean uniqueReference)
Does some crude english pluralization TODO: are the from/to names correct ?

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:

pluralize

protected String pluralize(String singular)

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.

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

tableToClassName

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

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

getTableIdentifierStrategyName

public String getTableIdentifierStrategyName(TableIdentifier identifier)
Specified by:
getTableIdentifierStrategyName in interface ReverseEngineeringStrategy
Parameters:
identifier - 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 rti)
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)
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)
Description copied from interface: ReverseEngineeringStrategy
Generic method used to initialize the reverse engineering strategy.

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

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.

getRoot

protected ReverseEngineeringStrategy getRoot()

getRuntimeInfo

protected ReverseEngineeringRuntimeInfo getRuntimeInfo()

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