net.sf.xaj.jdbc
Class JdbcXmlDb
java.lang.Object
net.sf.xaj.core.AbstractDiscoverableXmlDb
net.sf.xaj.jdbc.JdbcXmlDb
- All Implemented Interfaces:
- DiscoverableXmlDb, XmlDb
public class JdbcXmlDb
- extends AbstractDiscoverableXmlDb
Implementation of XmlDb for exectuing queries against a database via
JDBC.
This implementation supports only the
executeXQuery(net.sf.xaj.XmlDb.XQuerySearchCriteria) method. All others
throw a UnsupportedOperationException.
The configurable properties of this class are:
- jdbcTemplate
- The
JdbcTemplate from which to obtain JDBC connections from.
- preparedStatementCreatorResolver
- A
PreparedStatementCreatorResolver implementation to resolve a
PreparedStatementCreator from based on the passed in
XmlDb.XQuerySearchCriteria.
- createXmlResults
- If true treat result rows as non XML results, and turn each result
row into an XML element named after the
xmlResultsRowElementName
property. Otherwise, each row is assumed to return a single XML column.
- xmlResultsRowElementName
- When
createXmlResults is true then use this value as
the name of the XML element to create for each result row. Defaults to
DEFAULT_XML_RESULTS_ROW_ELEMENT_NAME. Can be set on a per-query
basis by providing a query variable on the key
CRITERIA_XML_RESULTS_ELEMENT_NAME_KEY, in which case the results
will not be treated as XML (even if createXmlResults is false)
and each element will be named the value of this variable.
- Version:
- $Revision: 72 $ $Date: 2008-04-08 20:07:30 +1200 (Tue, 08 Apr 2008) $
- Author:
- matt
| Methods inherited from class net.sf.xaj.core.AbstractDiscoverableXmlDb |
close, doClose, doInit, getExecutor, getServiceKey, getShutdownExecutorWaitSecs, getState, getTransactionTemplate, getXmlDb, init, isShutdownExecutorServiceOnClose, processBatch, setExecutor, setServiceKey, setShutdownExecutorServiceOnClose, setShutdownExecutorWaitSecs, setTransactionTemplate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_XML_RESULTS_ROW_ELEMENT_NAME
public static final java.lang.String DEFAULT_XML_RESULTS_ROW_ELEMENT_NAME
- The default value for the
xmlResultsRowElementName property.
- See Also:
- Constant Field Values
CRITERIA_XML_RESULTS_ELEMENT_NAME_KEY
public static final java.lang.String CRITERIA_XML_RESULTS_ELEMENT_NAME_KEY
- A query criteria variable that should be used to dynamically assign
a
xmlResultsRowElementName value for the query.
- See Also:
- Constant Field Values
JdbcXmlDb
public JdbcXmlDb()
executeXQuery
public XmlDb.XQuerySearchResults executeXQuery(XmlDb.XQuerySearchCriteria criteria)
getPreparedStatementCreator
protected org.springframework.jdbc.core.PreparedStatementCreator getPreparedStatementCreator(XmlDb.XQuerySearchCriteria searchCriteria)
- Get a
PreparedStatementCreator instance to generate the SQL query
to execute for the report.
This default implementation simply calls
PreparedStatementCreatorResolver#resolvePreparedStatementCreator()
and returns the results.
- Parameters:
searchCriteria - the search criteria
- Returns:
- the
PreparedStatementCreator
getTransactionHolder
protected BasicBatchTransactionHolder getTransactionHolder()
- Specified by:
getTransactionHolder in class AbstractDiscoverableXmlDb
getTransactionHolderKey
protected java.lang.Object getTransactionHolderKey()
- Specified by:
getTransactionHolderKey in class AbstractDiscoverableXmlDb
delete
public boolean delete(java.io.Serializable id)
deleteByXQuery
public java.lang.Integer deleteByXQuery(XmlDb.XQuerySearchCriteria criteria)
get
public XmlResource get(java.io.Serializable id)
storeXml
public java.io.Serializable storeXml(XmlResource resource)
getJdbcTemplate
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
- Returns:
- the jdbcTemplate
setJdbcTemplate
public void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
- Parameters:
jdbcTemplate - the jdbcTemplate to set
getPreparedStatementCreatorResolver
public PreparedStatementCreatorResolver getPreparedStatementCreatorResolver()
- Returns:
- the preparedStatementCreatorResolver
setPreparedStatementCreatorResolver
public void setPreparedStatementCreatorResolver(PreparedStatementCreatorResolver preparedStatementCreatorResolver)
- Parameters:
preparedStatementCreatorResolver - the preparedStatementCreatorResolver to set
isCreateXmlResults
public boolean isCreateXmlResults()
- Returns:
- the createXmlResults
setCreateXmlResults
public void setCreateXmlResults(boolean createXmlResults)
- Parameters:
createXmlResults - the createXmlResults to set
getXmlResultsRowElementName
public java.lang.String getXmlResultsRowElementName()
- Returns:
- the xmlResultsRowElementName
setXmlResultsRowElementName
public void setXmlResultsRowElementName(java.lang.String xmlResultsRowElementName)
- Parameters:
xmlResultsRowElementName - the xmlResultsRowElementName to set