Class AbstractStrategy

java.lang.Object
org.hibernate.tool.internal.reveng.strategy.AbstractStrategy
All Implemented Interfaces:
RevengStrategy
Direct Known Subclasses:
DefaultStrategy

public abstract class AbstractStrategy extends Object implements RevengStrategy
  • Constructor Details

    • AbstractStrategy

      public AbstractStrategy()
  • Method Details

    • columnToPropertyName

      public String columnToPropertyName(TableIdentifier table, String columnName)
      Description copied from interface: RevengStrategy
      Return a property name for a Column.
      Specified by:
      columnToPropertyName in interface RevengStrategy
      Parameters:
      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 RevengStrategy
      Parameters:
      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)
    • foreignKeyToInverseEntityName

      public String foreignKeyToInverseEntityName(String keyname, TableIdentifier fromTable, List<?> fromColumnNames, TableIdentifier referencedTable, List<?> referencedColumnNames, boolean uniqueReference)
      Description copied from interface: RevengStrategy
      Used to rename the inverse one-to-one properties.
      Specified by:
      foreignKeyToInverseEntityName in interface RevengStrategy
      Parameters:
      fromColumnNames - list of Column instances on the fromTable. Only col.getName() should be assumed to be correct
      referencedColumnNames - 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:
      null if use defaults or non-empty String with a specific name
    • foreignKeyToEntityName

      public String foreignKeyToEntityName(String keyname, TableIdentifier fromTable, List<?> fromColumnNames, TableIdentifier referencedTable, List<?> referencedColumnNames, boolean uniqueReference)
      Specified by:
      foreignKeyToEntityName in interface RevengStrategy
      Parameters:
      fromColumnNames - list of Column instances on the fromTable. Only col.getName() should be assumed to be correct
      referencedColumnNames - 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:
    • columnToHibernateTypeName

      public String columnToHibernateTypeName(TableIdentifier table, String columnName, int sqlType, int length, int precision, int scale, boolean nullable, boolean generatedIdentifier)
      Description copied from interface: RevengStrategy
      Gets the preferred Hibernate type for an SQL type.
      Specified by:
      columnToHibernateTypeName in interface RevengStrategy
      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 RevengStrategy
    • excludeColumn

      public boolean excludeColumn(TableIdentifier identifier, String columnName)
      Specified by:
      excludeColumn in interface RevengStrategy
    • tableToClassName

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

      public List<org.hibernate.mapping.ForeignKey> getForeignKeys(TableIdentifier referencedTable)
      Description copied from interface: RevengStrategy
      Gets the user defined foreign keys.
      Specified by:
      getForeignKeys in interface RevengStrategy
      Parameters:
      referencedTable - the table to get the foreign keys for
      Returns:
      a list of ForeignKey's
    • getTableIdentifierStrategyName

      public String getTableIdentifierStrategyName(TableIdentifier identifier)
      Specified by:
      getTableIdentifierStrategyName in interface RevengStrategy
      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 RevengStrategy
    • getPrimaryKeyColumnNames

      public List<String> getPrimaryKeyColumnNames(TableIdentifier identifier)
      Description copied from interface: RevengStrategy
      If a table does not have any primarykey columns reported, this method is called.
      Specified by:
      getPrimaryKeyColumnNames in interface RevengStrategy
      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: RevengStrategy
      Given a class name return the name for its composite id if it will have one.
      Specified by:
      classNameToCompositeIdName in interface RevengStrategy
      Parameters:
      className -
      Returns:
    • close

      public void close()
      Description copied from interface: RevengStrategy
      Close any resources this strategy might have used. Called after reverse engineering has been completed.
      Specified by:
      close in interface RevengStrategy
    • getOptimisticLockColumnName

      public String getOptimisticLockColumnName(TableIdentifier identifier)
      Return explicit which column name should be used for optimistic lock
      Specified by:
      getOptimisticLockColumnName in interface RevengStrategy
    • useColumnForOptimisticLock

      public boolean useColumnForOptimisticLock(TableIdentifier identifier, String column)
      Specified by:
      useColumnForOptimisticLock in interface RevengStrategy
    • getSchemaSelections

      public List<RevengStrategy.SchemaSelection> getSchemaSelections()
      Description copied from interface: RevengStrategy
      Return list of SchemaSelctors to be used when asking RevengDialect for metadata.
      Specified by:
      getSchemaSelections in interface RevengStrategy
      Returns:
      list of RevengStrategy.SchemaSelection instances
    • tableToIdentifierPropertyName

      public String tableToIdentifierPropertyName(TableIdentifier tableIdentifier)
      Description copied from interface: RevengStrategy
      Given a table name, return the wanted name for the identifier.
      Specified by:
      tableToIdentifierPropertyName in interface RevengStrategy
      Parameters:
      tableIdentifier -
      Returns:
      name to be used for identification
    • tableToCompositeIdName

      public String tableToCompositeIdName(TableIdentifier identifier)
      Description copied from interface: RevengStrategy
      Given a table name, return the wanted name for a composite identifier.
      Specified by:
      tableToCompositeIdName in interface RevengStrategy
      Parameters:
      identifier -
      Returns:
    • excludeForeignKeyAsCollection

      public boolean excludeForeignKeyAsCollection(String keyname, TableIdentifier fromTable, List<?> fromColumns, TableIdentifier referencedTable, List<?> referencedColumns)
      Description copied from interface: RevengStrategy
      Should this foreignkey be excluded as a oneToMany
      Specified by:
      excludeForeignKeyAsCollection in interface RevengStrategy
    • excludeForeignKeyAsManytoOne

      public boolean excludeForeignKeyAsManytoOne(String keyname, TableIdentifier fromTable, List<?> fromColumns, TableIdentifier referencedTable, List<?> referencedColumns)
      Description copied from interface: RevengStrategy
      Should this foreignkey be excluded as a many-to-one
      Specified by:
      excludeForeignKeyAsManytoOne in interface RevengStrategy
    • isForeignKeyCollectionInverse

      public boolean isForeignKeyCollectionInverse(String name, org.hibernate.mapping.Table foreignKeyTable, List<?> columns, org.hibernate.mapping.Table foreignKeyReferencedTable, List<?> referencedColumns)
      Specified by:
      isForeignKeyCollectionInverse in interface RevengStrategy
    • isForeignKeyCollectionLazy

      public boolean isForeignKeyCollectionLazy(String name, TableIdentifier foreignKeyTable, List<?> columns, TableIdentifier foreignKeyReferencedTable, List<?> referencedColumns)
      Description copied from interface: RevengStrategy
      is the collection lazy or not ?
      Specified by:
      isForeignKeyCollectionLazy in interface RevengStrategy
    • setSettings

      public void setSettings(RevengSettings settings)
      Description copied from interface: RevengStrategy
      Generic method used to initialize the reverse engineering strategy.
      Specified by:
      setSettings in interface RevengStrategy
      Parameters:
      settings - used for this
    • isOneToOne

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

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

      protected RevengStrategy getRoot()
    • foreignKeyToManyToManyName

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

      public Map<String,org.hibernate.mapping.MetaAttribute> tableToMetaAttributes(TableIdentifier tableIdentifier)
      Description copied from interface: RevengStrategy
      Return the list of metaattributes to assign to classes created based on the given table
      Specified by:
      tableToMetaAttributes in interface RevengStrategy
      Parameters:
      tableIdentifier -
      Returns:
      a Map from String to MetaAttribute
    • columnToMetaAttributes

      public Map<String,org.hibernate.mapping.MetaAttribute> columnToMetaAttributes(TableIdentifier identifier, String column)
      Description copied from interface: RevengStrategy
      Return the list of metaattributes to assign to properties created based on the given column
      Specified by:
      columnToMetaAttributes in interface RevengStrategy
      Parameters:
      column -
      Returns:
      a Map from String to MetaAttribute
    • foreignKeyToAssociationInfo

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

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