toolbox.dao.orm
Class ORMQueryServiceImpl

Package class diagram package ORMQueryServiceImpl
java.lang.Object
  extended by toolbox.services.BaseService
      extended by toolbox.services.dao.DaoService
          extended by toolbox.dao.orm.ORMQueryServiceImpl
All Implemented Interfaces:
ORMQueryService, Service

public class ORMQueryServiceImpl
extends DaoService
implements ORMQueryService

Default implementation of the ORMQueryService interface.

This implementation is driven by an external XML configuration document and it is assumend that entities are implementations of the toolbox.dao.DaoBean interface.

This implementation is also a subclass of the toolbox.services.dao.DaoService which makes it possible to incorporate it into a service registry configuration. Instances of this service must be configured as singletons within the service registry.


Constructor Summary
ORMQueryServiceImpl()
          Default constructor.
 
Method Summary
 void create(java.lang.String name, java.lang.String confHome, ServiceEnvironment env, XMLProperties xmlProps)
          Initialises the member ORMConfig instance using the provided XML configuration.
 java.util.List getReferenceIds(java.lang.String mapping)
          Return a List of Strings that contain the names of the reference columns for the given mapping.
 java.util.List resolve(java.lang.String mapping)
          Resolve the relationships of the named mapping.
 java.util.List resolve(java.lang.String mapping, java.util.Map params)
          Resolve the relationships of the named mapping and narrow the results using the provided query parameters.
 java.lang.Object resolve(java.lang.String mapping, java.lang.Object key)
          Resolve the relationships of a single database entity using a primary key value.
 java.util.List resolve(java.lang.String mapping, PreparedQuery query, java.lang.String postfix)
          Resolve the relationships of the named mapping and narrow the results using the provided PreparedQuery instance.
 void setReferences(java.lang.String mapping, java.lang.Object instance)
          Set all the relationships for the given entity instance, given that the reference identifiers are available on the entity.
 void setReferences(java.lang.String mapping, java.lang.Object instance, java.lang.Object[] refIds)
          Set all the relationships for the given entity instance.
 
Methods inherited from class toolbox.services.dao.DaoService
checkConstraint, destroy, doCustomQuery, doCustomQuery, getDaoManager, getDaoWorker, getNextSequenceValue, insertDaoBean, insertDaoBean, updateDaoBean, updateDaoBean
 
Methods inherited from class toolbox.services.BaseService
getConfigHome, getName, getProperties, getProperty, getXMLProperties, logConfig, logFine, logFiner, logFinest, logInfo, logSevere, logWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ORMQueryServiceImpl

public ORMQueryServiceImpl()
Default constructor.

Method Detail

create

public void create(java.lang.String name,
                   java.lang.String confHome,
                   ServiceEnvironment env,
                   XMLProperties xmlProps)
            throws ServiceException
Initialises the member ORMConfig instance using the provided XML configuration.

Specified by:
create in interface Service
Overrides:
create in class DaoService
Parameters:
name - The name of the service.
confHome - The path to the configuration home directory.
env - ServiceEnvironment of this service.
xmlProps - XML configuration properties.
Throws:
ServiceException - if the service cannot be created.

resolve

public java.util.List resolve(java.lang.String mapping)
                       throws DaoException
Resolve the relationships of the named mapping.

Specified by:
resolve in interface ORMQueryService
Parameters:
mapping - String containing the name of the relational mapping.
Returns:
List of Objects where each instance represents a database entity with all relationships resolved.
Throws:
DaoException - if the mapping cannot be resolved.

resolve

public java.util.List resolve(java.lang.String mapping,
                              java.util.Map params)
                       throws DaoException
Resolve the relationships of the named mapping and narrow the results using the provided query parameters.

Specified by:
resolve in interface ORMQueryService
Parameters:
mapping - String containing the name of the relational mapping.
params - Map instance containing query parameters.
Returns:
List of Objects where each instance represents a database entity with all relationships resolved.
Throws:
DaoException - if the mapping cannot be resolved.

resolve

public java.util.List resolve(java.lang.String mapping,
                              PreparedQuery query,
                              java.lang.String postfix)
                       throws DaoException
Resolve the relationships of the named mapping and narrow the results using the provided PreparedQuery instance.

Specified by:
resolve in interface ORMQueryService
Parameters:
mapping - String containing the name of the relational mapping.
query - PreparedQuery instance containing query parameters.
postfix - An optional postfix to append to the query.
Returns:
List of Objects where each instance represents a database entity with all relationships resolved.
Throws:
DaoException - if the mapping cannot be resolved.

resolve

public java.lang.Object resolve(java.lang.String mapping,
                                java.lang.Object key)
                         throws DaoException
Resolve the relationships of a single database entity using a primary key value.

Specified by:
resolve in interface ORMQueryService
Parameters:
mapping - String containing the name of the relational mapping.
key - Object instance containing the primary key of the entity to resolve.
Returns:
Object containing the database entity with all relationships resolved.
Throws:
DaoException - if the mapping cannot be resolved.

setReferences

public void setReferences(java.lang.String mapping,
                          java.lang.Object instance,
                          java.lang.Object[] refIds)
                   throws DaoException
Set all the relationships for the given entity instance.

Specified by:
setReferences in interface ORMQueryService
Parameters:
mapping - String containing the name of the relational mapping.
instance - Object instance that represents an entity with none of it's relationships resolved.
refIds - Object array containing the identifiers of the entities that are referenced by the entity instance.
Throws:
DaoException - if the relationships cannot resolved and applied to the given entity instance.

setReferences

public void setReferences(java.lang.String mapping,
                          java.lang.Object instance)
                   throws DaoException
Set all the relationships for the given entity instance, given that the reference identifiers are available on the entity.

Specified by:
setReferences in interface ORMQueryService
Parameters:
mapping - String containing the name of the relational mapping.
instance - Object instance that represents an entity with none of it's relationships resolved.
Throws:
DaoException - if the relationships cannot resolved and applied to the given entity instance.

getReferenceIds

public java.util.List getReferenceIds(java.lang.String mapping)
Return a List of Strings that contain the names of the reference columns for the given mapping.

Specified by:
getReferenceIds in interface ORMQueryService
Parameters:
mapping - String containing the name of the relational mapping.
Returns:
List containing the reference column names for the given mapping.