Package org.apache.cayenne.access

## Class DataNode

- java.lang.Object
- - org.apache.cayenne.access.DataNode

- All Implemented Interfaces:
    `QueryEngine`

      public class DataNode
      extends Object
      implements QueryEngine

  An abstraction of a single physical data storage. This is usually a database server, but can potentially be some other storage type like an LDAP server, etc.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected DbAdapter` | `adapter` |
    `protected Map<String,​DataMap>` | `dataMaps` |
    `protected DataSource` | `dataSource` |
    `protected String` | `dataSourceFactory` |
    `protected String` | `dataSourceLocation` |
    `protected EntityResolver` | `entityResolver` |
    `protected String` | `name` |
    `protected SchemaUpdateStrategy` | `schemaUpdateStrategy` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DataNode()` | Creates a new unnamed DataNode.
    `DataNode​(String name)` | Creates a new DataNode, assigning it a name.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addDataMap​(DataMap map)` | Adds a DataMap to be handled by this node.
    `BatchTranslator` | `batchTranslator​(BatchQuery query, String trimFunction)` |
    `DbAdapter` | `getAdapter()` | Returns DbAdapter object.
    `BatchTranslatorFactory` | `getBatchTranslatorFactory()` |
    `DataMap` | `getDataMap​(String name)` | Returns datamap with specified name, null if none present
    `Collection<DataMap>` | `getDataMaps()` | Returns an unmodifiable collection of DataMaps handled by this DataNode.
    `DataSource` | `getDataSource()` | Returns DataSource used by this DataNode to obtain connections.
    `String` | `getDataSourceFactory()` | Returns a name of DataSourceFactory class for this node.
    `EntityResolver` | `getEntityResolver()` | Returns EntityResolver that handles DataMaps of this node.
    `JdbcEventLogger` | `getJdbcEventLogger()` |
    `String` | `getName()` | Returns node name.
    `RowReaderFactory` | `getRowReaderFactory()` |
    `SchemaUpdateStrategy` | `getSchemaUpdateStrategy()` |
    `SelectTranslatorFactory` | `getSelectTranslatorFactory()` |
    `SQLTemplateProcessor` | `getSqlTemplateProcessor()` |
    `DataNode` | `lookupDataNode​(DataMap dataMap)` | Returns a DataNode that should handle queries for all DataMap components.
    `void` | `performQueries​(Collection<? extends Query> queries, OperationObserver callback)` | Runs queries using Connection obtained from internal DataSource.
    `void` | `removeDataMap​(String mapName)` |
    `void` | `removeDataMap​(DataMap map)` |
    `RowReader<?>` | `rowReader​(RowDescriptor descriptor, QueryMetadata queryMetadata)` | Creates a `RowReader` using internal `RowReaderFactory`.
    `RowReader<?>` | `rowReader​(RowDescriptor descriptor, QueryMetadata queryMetadata, Map<ObjAttribute,​ColumnDescriptor> attributeOverrides)` | Creates a `RowReader` using internal `RowReaderFactory`.
    `SelectTranslator` | `selectTranslator​(Select<?> query)` |
    `void` | `setAdapter​(DbAdapter adapter)` |
    `void` | `setBatchTranslatorFactory​(BatchTranslatorFactory batchTranslatorFactory)` |
    `void` | `setDataMaps​(Collection<DataMap> dataMaps)` |
    `void` | `setDataSource​(DataSource dataSource)` |
    `void` | `setDataSourceFactory​(String dataSourceFactory)` |
    `void` | `setEntityResolver​(EntityResolver entityResolver)` | Sets EntityResolver.
    `void` | `setJdbcEventLogger​(JdbcEventLogger logger)` |
    `void` | `setName​(String name)` |
    `void` | `setRowReaderFactory​(RowReaderFactory rowReaderFactory)` |
    `void` | `setSchemaUpdateStrategy​(SchemaUpdateStrategy schemaUpdateStrategy)` |
    `void` | `setSelectTranslatorFactory​(SelectTranslatorFactory selectTranslatorFactory)` |
    `void` | `setSqlTemplateProcessor​(SQLTemplateProcessor sqlTemplateProcessor)` |
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### name

          protected String name

    - #### dataSource

          protected DataSource dataSource

    - #### adapter

          protected DbAdapter adapter

    - #### dataSourceLocation

          protected String dataSourceLocation

    - #### dataSourceFactory

          protected String dataSourceFactory

    - #### entityResolver

          protected EntityResolver entityResolver

    - #### schemaUpdateStrategy

          protected SchemaUpdateStrategy schemaUpdateStrategy

    - #### dataMaps

          protected Map<String,​DataMap> dataMaps

  - ### Constructor Detail

    - #### DataNode

          public DataNode()

      Creates a new unnamed DataNode.

    - #### DataNode

          public DataNode​(String name)

      Creates a new DataNode, assigning it a name.

  - ### Method Detail

    - #### getSchemaUpdateStrategy

          public SchemaUpdateStrategy getSchemaUpdateStrategy()

      Since:
        3.0

    - #### setSchemaUpdateStrategy

          public void setSchemaUpdateStrategy​(SchemaUpdateStrategy schemaUpdateStrategy)

      Since:
        3.0

    - #### getJdbcEventLogger

          public JdbcEventLogger getJdbcEventLogger()

      Since:
        3.1

    - #### setJdbcEventLogger

          public void setJdbcEventLogger​(JdbcEventLogger logger)

      Since:
        3.1

    - #### getName

          public String getName()

      Returns node name. Name is used to uniquely identify DataNode within a DataDomain.

    - #### setName

          public void setName​(String name)

    - #### getDataSourceFactory

          public String getDataSourceFactory()

      Returns a name of DataSourceFactory class for this node.

    - #### setDataSourceFactory

          public void setDataSourceFactory​(String dataSourceFactory)

    - #### getDataMaps

          public Collection<DataMap> getDataMaps()

      Returns an unmodifiable collection of DataMaps handled by this DataNode.

    - #### getDataMap

          public DataMap getDataMap​(String name)

      Returns datamap with specified name, null if none present

    - #### setDataMaps

          public void setDataMaps​(Collection<DataMap> dataMaps)

    - #### addDataMap

          public void addDataMap​(DataMap map)

      Adds a DataMap to be handled by this node.

    - #### removeDataMap

          public void removeDataMap​(DataMap map)

    - #### removeDataMap

          public void removeDataMap​(String mapName)

    - #### getDataSource

          public DataSource getDataSource()

      Returns DataSource used by this DataNode to obtain connections.

    - #### setDataSource

          public void setDataSource​(DataSource dataSource)

    - #### getAdapter

          public DbAdapter getAdapter()

      Returns DbAdapter object. This is a plugin that handles RDBMS vendor-specific features.

    - #### setAdapter

          public void setAdapter​(DbAdapter adapter)

    - #### lookupDataNode

          public DataNode lookupDataNode​(DataMap dataMap)

      Returns a DataNode that should handle queries for all DataMap components.
      Since:
        1.1

    - #### performQueries

          public void performQueries​(Collection<? extends Query> queries,
                                     OperationObserver callback)

      Runs queries using Connection obtained from internal DataSource.
      Specified by:
        `performQueries` in interface `QueryEngine`
      Since:
        1.1

    - #### getEntityResolver

          public EntityResolver getEntityResolver()

      Returns EntityResolver that handles DataMaps of this node.
      Specified by:
        `getEntityResolver` in interface `QueryEngine`

    - #### setEntityResolver

          public void setEntityResolver​(EntityResolver entityResolver)

      Sets EntityResolver. DataNode relies on externally set EntityResolver, so if the node is created outside of DataDomain stack, a valid EntityResolver must be provided explicitly.
      Since:
        1.1

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### rowReader

          public RowReader<?> rowReader​(RowDescriptor descriptor,
                                        QueryMetadata queryMetadata)

      Creates a `RowReader` using internal `RowReaderFactory`.
      Since:
        4.0

    - #### rowReader

          public RowReader<?> rowReader​(RowDescriptor descriptor,
                                        QueryMetadata queryMetadata,
                                        Map<ObjAttribute,​ColumnDescriptor> attributeOverrides)

      Creates a `RowReader` using internal `RowReaderFactory`.
      Since:
        4.0

    - #### batchTranslator

          public BatchTranslator batchTranslator​(BatchQuery query,
                                                 String trimFunction)

      Since:
        4.0

    - #### selectTranslator

          public SelectTranslator selectTranslator​(Select<?> query)

      Since:
        4.0

    - #### getRowReaderFactory

          public RowReaderFactory getRowReaderFactory()

      Since:
        4.0

    - #### setRowReaderFactory

          public void setRowReaderFactory​(RowReaderFactory rowReaderFactory)

      Since:
        4.0

    - #### getBatchTranslatorFactory

          public BatchTranslatorFactory getBatchTranslatorFactory()

      Since:
        4.0

    - #### setBatchTranslatorFactory

          public void setBatchTranslatorFactory​(BatchTranslatorFactory batchTranslatorFactory)

      Since:
        4.0

    - #### getSqlTemplateProcessor

          public SQLTemplateProcessor getSqlTemplateProcessor()

      Since:
        4.0

    - #### setSqlTemplateProcessor

          public void setSqlTemplateProcessor​(SQLTemplateProcessor sqlTemplateProcessor)

      Since:
        4.0

    - #### getSelectTranslatorFactory

          public SelectTranslatorFactory getSelectTranslatorFactory()

      Since:
        4.0

    - #### setSelectTranslatorFactory

          public void setSelectTranslatorFactory​(SelectTranslatorFactory selectTranslatorFactory)

      Since:
        4.0