org.apache.cayenne.access
Class DataNode

java.lang.Object
  extended by org.apache.cayenne.access.DataNode
All Implemented Interfaces:
QueryEngine
Direct Known Subclasses:
OracleDataNode

public class DataNode
extends java.lang.Object
implements QueryEngine

Describes a single physical data source. This can be a database server, LDAP server, etc.

For more information see Cayenne User Guide.

Author:
Andrus Adamchik

Field Summary
protected  DbAdapter adapter
           
protected  java.util.Map dataMaps
           
protected  javax.sql.DataSource dataSource
           
protected  java.lang.String dataSourceFactory
           
protected  java.lang.String dataSourceLocation
           
static java.lang.Class DEFAULT_ADAPTER_CLASS
          Deprecated. since 1.2 unused.
protected  EntityResolver entityResolver
           
protected  EntitySorter entitySorter
           
protected  java.lang.String name
           
 
Constructor Summary
DataNode()
          Creates a new unnamed DataNode.
DataNode(java.lang.String name)
          Creates a new DataNode, assigning it a name.
 
Method Summary
 void addDataMap(DataMap map)
          Adds a DataMap to be handled by this node.
 DbAdapter getAdapter()
          Returns DbAdapter object.
 java.util.Collection getDataMaps()
          Returns an unmodifiable collection of DataMaps handled by this DataNode.
 javax.sql.DataSource getDataSource()
          Returns DataSource used by this DataNode to obtain connections.
 java.lang.String getDataSourceFactory()
          Returns a name of DataSourceFactory class for this node.
 java.lang.String getDataSourceLocation()
          Returns a location of DataSource of this node.
 EntityResolver getEntityResolver()
          Returns EntityResolver that handles DataMaps of this node.
 EntitySorter getEntitySorter()
          Returns EntitySorter used by the DataNode.
 java.lang.String getName()
          Returns node name.
 DataNode lookupDataNode(DataMap dataMap)
          Returns a DataNode that should hanlde queries for all DataMap components.
 void performQueries(java.util.Collection queries, OperationObserver callback)
          Runs queries using Connection obtained from internal DataSource.
 void performQueries(java.util.Collection queries, OperationObserver observer, Transaction transaction)
          Deprecated. since 1.2 as the corresponding interface method is deprecated.
protected  void readResultSet(java.sql.ResultSet resultSet, ResultDescriptor descriptor, GenericSelectQuery query, OperationObserver delegate)
          Deprecated. Since 1.2 this logic is moved to SQLAction.
protected  void readStoredProcedureOutParameters(java.sql.CallableStatement statement, ResultDescriptor descriptor, Query query, OperationObserver delegate)
          Deprecated. Since 1.2 this logic is moved to SQLAction.
 void removeDataMap(java.lang.String mapName)
           
protected  void runBatchUpdate(java.sql.Connection connection, BatchQuery query, OperationObserver observer)
          Deprecated. since 1.2
protected  void runBatchUpdateAsBatch(java.sql.Connection con, BatchQuery query, BatchQueryBuilder queryBuilder, OperationObserver delegate)
          Deprecated. since 1.2 SQLActions are used.
protected  void runBatchUpdateAsIndividualQueries(java.sql.Connection con, BatchQuery query, BatchQueryBuilder queryBuilder, OperationObserver delegate)
          Deprecated. since 1.2 SQLActions are used.
protected  void runSelect(java.sql.Connection connection, Query query, OperationObserver observer)
          Deprecated. since 1.2
protected  void runStoredProcedure(java.sql.Connection con, Query query, OperationObserver delegate)
          Deprecated. since 1.2
protected  void runUpdate(java.sql.Connection con, Query query, OperationObserver delegate)
          Deprecated. since 1.2
 void setAdapter(DbAdapter adapter)
           
 void setDataMaps(java.util.Collection dataMaps)
           
 void setDataSource(javax.sql.DataSource dataSource)
           
 void setDataSourceFactory(java.lang.String dataSourceFactory)
           
 void setDataSourceLocation(java.lang.String dataSourceLocation)
           
 void setEntityResolver(EntityResolver entityResolver)
          Sets EntityResolver.
 void setEntitySorter(EntitySorter entitySorter)
          Sets an EntitySorter that is used to order objects on commit.
 void setName(java.lang.String name)
           
 void shutdown()
          Tries to close JDBC connections opened by this node's data source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ADAPTER_CLASS

public static final java.lang.Class DEFAULT_ADAPTER_CLASS
Deprecated. since 1.2 unused.

name

protected java.lang.String name

dataSource

protected javax.sql.DataSource dataSource

adapter

protected DbAdapter adapter

dataSourceLocation

protected java.lang.String dataSourceLocation

dataSourceFactory

protected java.lang.String dataSourceFactory

entityResolver

protected EntityResolver entityResolver

entitySorter

protected EntitySorter entitySorter

dataMaps

protected java.util.Map dataMaps
Constructor Detail

DataNode

public DataNode()
Creates a new unnamed DataNode.


DataNode

public DataNode(java.lang.String name)
Creates a new DataNode, assigning it a name.

Method Detail

getName

public java.lang.String getName()
Returns node name. Name is used to uniquely identify DataNode within a DataDomain.


setName

public void setName(java.lang.String name)

getDataSourceLocation

public java.lang.String getDataSourceLocation()
Returns a location of DataSource of this node. Depending on how this node was created, location is either a JNDI name, or a location of node XML file, etc.


setDataSourceLocation

public void setDataSourceLocation(java.lang.String dataSourceLocation)

getDataSourceFactory

public java.lang.String getDataSourceFactory()
Returns a name of DataSourceFactory class for this node.


setDataSourceFactory

public void setDataSourceFactory(java.lang.String dataSourceFactory)

getDataMaps

public java.util.Collection getDataMaps()
Returns an unmodifiable collection of DataMaps handled by this DataNode.

Specified by:
getDataMaps in interface QueryEngine

setDataMaps

public void setDataMaps(java.util.Collection dataMaps)

addDataMap

public void addDataMap(DataMap map)
Adds a DataMap to be handled by this node.


removeDataMap

public void removeDataMap(java.lang.String mapName)

getDataSource

public javax.sql.DataSource getDataSource()
Returns DataSource used by this DataNode to obtain connections.


setDataSource

public void setDataSource(javax.sql.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 hanlde queries for all DataMap components.

Specified by:
lookupDataNode in interface QueryEngine
Since:
1.1

performQueries

public void performQueries(java.util.Collection queries,
                           OperationObserver observer,
                           Transaction transaction)
Deprecated. since 1.2 as the corresponding interface method is deprecated.

Description copied from interface: QueryEngine
Executes queries in the transactional context provided by the caller. It is caller's responsibility to commit or rollback the Transaction and close any connections that were added to it.

Specified by:
performQueries in interface QueryEngine

performQueries

public void performQueries(java.util.Collection queries,
                           OperationObserver callback)
Runs queries using Connection obtained from internal DataSource.

Specified by:
performQueries in interface QueryEngine
Since:
1.1

runSelect

protected void runSelect(java.sql.Connection connection,
                         Query query,
                         OperationObserver observer)
                  throws java.sql.SQLException,
                         java.lang.Exception
Deprecated. since 1.2

Executes a SelectQuery.

Throws:
java.sql.SQLException
java.lang.Exception

runUpdate

protected void runUpdate(java.sql.Connection con,
                         Query query,
                         OperationObserver delegate)
                  throws java.sql.SQLException,
                         java.lang.Exception
Deprecated. since 1.2

Executes a non-batched updating query.

Throws:
java.sql.SQLException
java.lang.Exception

runBatchUpdate

protected void runBatchUpdate(java.sql.Connection connection,
                              BatchQuery query,
                              OperationObserver observer)
                       throws java.sql.SQLException,
                              java.lang.Exception
Deprecated. since 1.2

Executes a batch updating query.

Throws:
java.sql.SQLException
java.lang.Exception

runBatchUpdateAsBatch

protected void runBatchUpdateAsBatch(java.sql.Connection con,
                                     BatchQuery query,
                                     BatchQueryBuilder queryBuilder,
                                     OperationObserver delegate)
                              throws java.sql.SQLException,
                                     java.lang.Exception
Deprecated. since 1.2 SQLActions are used.

Executes batch query using JDBC Statement batching features.

Throws:
java.sql.SQLException
java.lang.Exception

runBatchUpdateAsIndividualQueries

protected void runBatchUpdateAsIndividualQueries(java.sql.Connection con,
                                                 BatchQuery query,
                                                 BatchQueryBuilder queryBuilder,
                                                 OperationObserver delegate)
                                          throws java.sql.SQLException,
                                                 java.lang.Exception
Deprecated. since 1.2 SQLActions are used.

Executes batch query without using JDBC Statement batching features, running individual statements in the batch one by one.

Throws:
java.sql.SQLException
java.lang.Exception

runStoredProcedure

protected void runStoredProcedure(java.sql.Connection con,
                                  Query query,
                                  OperationObserver delegate)
                           throws java.sql.SQLException,
                                  java.lang.Exception
Deprecated. since 1.2

Throws:
java.sql.SQLException
java.lang.Exception

readStoredProcedureOutParameters

protected void readStoredProcedureOutParameters(java.sql.CallableStatement statement,
                                                ResultDescriptor descriptor,
                                                Query query,
                                                OperationObserver delegate)
                                         throws java.sql.SQLException,
                                                java.lang.Exception
Deprecated. Since 1.2 this logic is moved to SQLAction.

Helper method that reads OUT parameters of a CallableStatement.

Throws:
java.sql.SQLException
java.lang.Exception

readResultSet

protected void readResultSet(java.sql.ResultSet resultSet,
                             ResultDescriptor descriptor,
                             GenericSelectQuery query,
                             OperationObserver delegate)
                      throws java.sql.SQLException,
                             java.lang.Exception
Deprecated. Since 1.2 this logic is moved to SQLAction.

Helper method that reads a ResultSet.

Throws:
java.sql.SQLException
java.lang.Exception

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

getEntitySorter

public EntitySorter getEntitySorter()
Returns EntitySorter used by the DataNode.


setEntitySorter

public void setEntitySorter(EntitySorter entitySorter)
Sets an EntitySorter that is used to order objects on commit.

Since:
1.2

shutdown

public void shutdown()
Tries to close JDBC connections opened by this node's data source.



Copyright © 2001-2006 Apache.org All Rights Reserved.