org.compass.gps.device.jdbc.mapping
Class TableToResourceMapping

java.lang.Object
  extended by org.compass.gps.device.jdbc.mapping.ResultSetToResourceMapping
      extended by org.compass.gps.device.jdbc.mapping.TableToResourceMapping
All Implemented Interfaces:
AutoGenerateMapping

public class TableToResourceMapping
extends ResultSetToResourceMapping
implements AutoGenerateMapping

A specialized form of ResultSetToResourceMapping, mapping a specfic database table to a resource.

Since the mapping works against a table, most of the parameters can be automatically generated. The required mappings are the alias name and the table name. The settings that can be generated are the id mappings (based on the table primary keys), the select query (based on the table name), and the version query (based on the table name and the version column mappings).

If no data column mappings are provided, the indexUnMappedColumns from ResultSetToResourceMapping can be user to auto map all the table columns as data columns.

For real time mirroring, at least one version column mapping (VersionColumnMapping) is required. And the version query can be auto generated.

Note that the mapping will auto generate only settings that have not been set. If, for example, the select query was set, it will not be generated.

Author:
kimchy

Constructor Summary
TableToResourceMapping()
          Creates a new table to Resource mapping.
TableToResourceMapping(String tableName, String alias)
          Creates a new table to Resource mapping with the given table name and alias.
 
Method Summary
 void generateMappings(DataSource dataSource)
          Generates the unset mappings.
 String getTableName()
          Returns the table name that the mappings maps to.
 void setTableName(String tableName)
          Sets the table name that the mappings maps to.
 String toString()
           
 
Methods inherited from class org.compass.gps.device.jdbc.mapping.ResultSetToResourceMapping
addDataMapping, addIdMapping, addVersionMapping, dataMappingsIt, dataMappingsSize, getAlias, getMappingsForColumn, getMappingsForColumn, getSelectQuery, getVersionQuery, idMappingsIt, idMappingsSize, isIndexUnMappedColumns, mappingsIt, setAlias, setDataMappings, setIdMappings, setIndexUnMappedColumns, setSelectQuery, setVersionMappings, setVersionQuery, supportsVersioning, versionMappingsIt, versionMappingsSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableToResourceMapping

public TableToResourceMapping()
Creates a new table to Resource mapping. Must set the alias, and the table name.

Indexing of unmapped columns is diasabled by default.


TableToResourceMapping

public TableToResourceMapping(String tableName,
                              String alias)
Creates a new table to Resource mapping with the given table name and alias.

Indexing of unmapped columns is disabled by default.

Parameters:
tableName - The table name
alias - The Resource alias
Method Detail

generateMappings

public void generateMappings(DataSource dataSource)
                      throws JdbcGpsDeviceException
Generates the unset mappings.

Generates the id mappings based on the table primary keys if no id column mappings are set.

Generates the select query based on the table name if no select query is set.

Generates the version query based on the table name and the version column mappings if no version query is set and at least one version column mapping is set.

Specified by:
generateMappings in interface AutoGenerateMapping
Throws:
JdbcGpsDeviceException

getTableName

public String getTableName()
Returns the table name that the mappings maps to.


setTableName

public void setTableName(String tableName)
Sets the table name that the mappings maps to.


toString

public String toString()
Overrides:
toString in class ResultSetToResourceMapping


Copyright (c) 2004-2008 The Compass Project.