Anyframe Core

anyframe.core.query
Interface IQueryService


public interface IQueryService

This Service simplifies the use of JDBC and helps to avoid common errors. It executes core JDBC workflow, leaving application code to provide SQL and extract results. This class executes query statement or updates, initiating iteration over ResultSets. It must be used with DataSource Service.

QueryService Configuration Example:

 <bean name="queryService" class="anyframe.core.query.impl.QueryServiceImpl">
      <property name="jdbcTemplate" ref="jdbcTemplate"/>
      <property name="sqlRepository" ref="sqlLoader"/>
      <property name="pagingSQLGenerator" ref="pagingSQLGenerator"/>
      <property name="lobHandler" ref="lobHandler"/>
 </bean>
  
 <bean id="jdbcTemplate" class="anyframe.core.query.impl.jdbc.PagingJdbcTemplate">
      <property name="dataSource" ref="dataSource" />
      <property name="exceptionTranslator" ref="exceptionTranslator" />
 </bean>
 
 <bean name="sqlLoader" class="anyframe.core.query.impl.config.loader.SQLLoader">
      <config:configuration>
              <!-- xml files in folder -->
              <filename>file:./testmappings/testcase-*.xml</filename>
              <filename>file:./testdynamicreload/testcase-queries-dynamicreload.xml</filename> 
              <!-- xml files in classpath -->
              <filename>classpath*:/META-INF/mappings/testcase-queries-*.xml</filename>
              <!-- xml files in jar  -->
              <filename>classpath*:/testcase-queries-lob.xml</filename>
              <nullcheck type="VARCHAR" default-value="" />
              <sqlload dynamic="true" frequency="5" />
              <skiperror>true</skiperror>
      </config:configuration>
 </bean>
 
 <bean id="pagingSQLGenerator" class="anyframe.core.query.impl.jdbc.generator.OraclePagingSQLGenerator"/>
 
 <bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler"
      lazy-init="true"> 
      <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/> 
 </bean>
 
 <bean id="exceptionTranslator" class="anyframe.core.query.impl.util.RawSQLExceptionTranslator"/>
 
 <bean id="nativeJdbcExtractor" 
      class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
      lazy-init="true"/>
 
Query Mapping XML Example:
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE queryservice PUBLIC "-//ANYFRAME//DTD QUERYSERVICE//EN"
 "http://www.anyframejava.org/dtd/anyframe-core-query-mapping-3.1.dtd">
      <queryservice>
              <table-mapping>
                      <table name="TBL_CUSTOMER" class="anyframe.core.query.Customer">
                              <field-mapping>
                                      <dbms-column>SSNO</dbms-column>
                                      <class-attribute>ssno</class-attribute>
                              </field-mapping>
                              <field-mapping>
                                      <dbms-column>NAME</dbms-column>
                                      <class-attribute>nm</class-attribute>
                              </field-mapping>
                              <primary-key>
                                      <dbms-column>SSNO</dbms-colum>
                              </primary-key>
                      </table>
              </table-mapping>
              <queries>
                      <query id="query01" isDynamic="true" isCamelCase="true">
                              <statement>
                                      select NAME, ADDRESS from TBL_CUSTOMER where SSNO like ?
                              </statement>
                              <param type="VARCHAR"/>
                              <result length=2 class="anyframe.core.query.Customer"/>  
                      </query>
              </queries>
         </queryservice>
 

Configuration Attributes: Mapping XML file has <queryservice> </queryservice> element which is composed with table-mapping tag and queries tag. table-mapping tag, queries tag is a required element.

table-mapping tag

queries tag

Let's start with a simple example.

The following class is the Persistent Object Class mapped to the upper sample Query Mapping file.

 package anyframe.core.query;
 
 import java.io.Serializable;
 
 public class CustomerVO implements Serializable {
     public String ssno;
 
     public String nm;
 
     public Customer() {
     }
 
     public Customer(String s, String n) {
         ssno = s;
         nm = n;
     }
 
     public String getSsno() {
         return ssno;
     }
 
     public String getNm() {
         return nm;
     }
 
     public void setSsno(String s) {
         ssno = s;
     }
 
     public void setNm(String n) {
         nm = n;
     }
 }
 

QueryService Service Client Example

 public class Main {
     public static void main(String args[]) throws Exception {
         ApplicationContext applicationContext =
             new ClasspathXmlApplicationContext(new String[] {"..." });
         QueryService qs =
             (applicationContext) applicationContext.getBean("queryService");
         qs.create("query03", new Object[] {"1234567890123", "AAA" });
         Collection allCustomer = qs.find("query01", new Object[] {"12345%" });
         Collection customer = qs.find("query01", new Object[] {"12345%" }, 1);
         qs.update("query04", new Object[] {"1234567890123", "BBB" });
         qs.remove("query05", new Object[] {"1234567890123" });
     }
 }
 

Author:
SoYon Lim

Field Summary
static String COL_INFO
           
static String COUNT
           
static String LIST
           
static Log LOGGER
           
static String ROLE
           
 
Method Summary
 int[] batchCreate(List targets)
          Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method
 int[] batchRemove(List targets)
          Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method
 int[] batchUpdate(List targets)
          Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method
 int[] batchUpdate(String queryId, List targets)
          Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method
 int[] batchUpdateBySQL(String sql, String[] types, List targets)
          Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method Execute UPDATE query, Using query statement directly without being defined in mapping xml files.
 int countQuery()
          Count all queries which defined in mapping xml files.
 int create(Object obj)
          Execute INSERT query, Using object, which class is matched with table by mapping xml files.
 int create(String queryId, Object[] values)
          Execute INSERT query, Using given queryId which defined in mapping xml files.
 int createBySQL(String sql, String[] types, Object[] values)
          Execute INSERT query, Using query statement directly without being defined in mapping xml files.
 Map execute(String queryId, Map values)
          Execute an sql call using a CallableStatement
 Map execute(String queryId, Map values, int pageIndex)
          Execute an SELECT sql call using a CallableStatement which defined in mapping xml files.
 Map execute(String queryId, Map values, int pageIndex, int pageSize)
          Execute an SELECT sql call using a CallableStatement which defined in mapping xml files.
 Map executeBySQL(String sql, String[] types, String[] names, String[] bindings, Map values)
          Execute an Sql call using a CallableStatement
 Map executeBySQL(String sql, String[] types, String[] names, String[] bindings, Map values, int pageIndex, int pageSize)
          Execute an Sql call using a CallableStatement
 Collection find(Object obj)
          Execute a SELECT query, Using object, which class is matched with table by mapping xml files.
 Collection find(String queryId, Object[] values)
          Execute a SELECT query, Using given queryId which defined in mapping xml files.
 Collection find(String queryId, Object[] values, int pageIndex)
          Execute a SELECT query, Using given queryId which defined in mapping xml files.
 Collection find(String queryId, Object[] values, int pageIndex, int pageSize)
          Execute a SELECT query, Using given queryId which defined in mapping xml files.
 Collection findBySQL(String sql, String[] types, Object[] values)
          Execute a SELECT query, Using query statement directly without being defined in mapping xml files.
 Collection findBySQL(String sql, String[] types, Object[] values, int pageIndex, int pageSize)
          Execute a SELECT query, Using query statement directly without being defined in mapping xml files.
 Map findBySQLWithRowCount(String sql, String[] types, Object[] values)
          Execute a SELECT query, Using query statement directly without being defined in mapping xml files.
 Map findBySQLWithRowCount(String sql, String[] types, Object[] values, int pageIndex, int pageSize)
          Execute a SELECT query, Using query statement directly without being defined in mapping xml files.
 Map findWithColInfo(String queryId, Object[] values)
          Execute a SELECT query, using given queryId which defined in mapping xml files.
 Map findWithColInfo(String queryId, Object[] values, int pageIndex)
          Execute a SELECT query, using given queryId which defined in mapping xml files.
 Map findWithColInfo(String queryId, Object[] values, int pageIndex, int pageSize)
          Execute a SELECT query, using given queryId which defined in mapping xml files.
 Map findWithRowCount(String queryId, Object[] values)
          Execute a SELECT query, using given queryId which defined in mapping xml files.
 Map findWithRowCount(String queryId, Object[] values, int pageIndex)
          Execute a SELECT query, using given queryId which defined in mapping xml files.
 Map findWithRowCount(String queryId, Object[] values, int pageIndex, int pageSize)
          Execute a SELECT query, using given queryId which defined in mapping xml files.
 IQueryInfo getQueryInfo(String queryId)
          Find specified query information which queryId equal to input parameter.
 Map getQueryMap()
          Find all query list which defined in mapping xml files.
 ArrayList getQueryParams(String queryId)
          Find parameters for specified query.
 JdbcTemplate getQueryServiceJdbcTemplate()
          Get JdbcTemplate which QueryService uses
 String getStatement(String queryId)
          Find specified query statement which queryId equal to input parameter.
 int remove(Object obj)
          Execute DELETE query, using object, which class is matched with table by mapping xml files.
 int remove(String queryId, Object[] values)
          Execute DELETE query, using given queryId which defined in mapping xml files.
 int removeBySQL(String sql, String[] types, Object[] values)
          Execute DELETE query, using query statement directly without being defined in mapping xml files.
 int update(Object obj)
          Execute UPDATE query, using object, which class is matched with table by mapping xml files.
 int update(String queryId, Object[] values)
          Execute UPDATE query, using given queryId which defined in mapping xml files.
 int updateBySQL(String sql, String[] types, Object[] values)
          Execute UPDATE query, using query statement directly without being defined in mapping xml files.
 

Field Detail

LOGGER

static final Log LOGGER

ROLE

static final String ROLE

COL_INFO

static final String COL_INFO
See Also:
Constant Field Values

COUNT

static final String COUNT
See Also:
Constant Field Values

LIST

static final String LIST
See Also:
Constant Field Values
Method Detail

batchCreate

int[] batchCreate(List targets)
                  throws QueryServiceException
Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method

Parameters:
targets - object of class which is matched with specified table in mapping xml files. is the List type of Object.
Returns:
an array of the number of rows affected by each statement
Throws:
QueryServiceException - if there is any problem issuing the update

batchRemove

int[] batchRemove(List targets)
                  throws QueryServiceException
Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method

Parameters:
targets - object of class which is matched with specified table in mapping xml files. is the List type of Object.
Returns:
an array of the number of rows affected by each statement
Throws:
QueryServiceException - if there is any problem issuing the update

batchUpdate

int[] batchUpdate(List targets)
                  throws QueryServiceException
Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method

Parameters:
targets - object of class which is matched with specified table in mapping xml files. is the List type of Object.
Returns:
an array of the number of rows affected by each statement
Throws:
QueryServiceException - if there is any problem issuing the update

batchUpdate

int[] batchUpdate(String queryId,
                  List targets)
                  throws QueryServiceException
Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method

Parameters:
queryId - identifier of query statement to execute
targets - a set of variable for executing query (is the List of Object[])
Returns:
an array of the number of rows affected by each statement
Throws:
QueryServiceException - if there is any problem issuing the update

batchUpdateBySQL

int[] batchUpdateBySQL(String sql,
                       String[] types,
                       List targets)
                       throws QueryServiceException
Issue multiple updates using JDBC 2.0 batch updates and PreparedStatementSetters to set values on a PreparedStatement created by this method Execute UPDATE query, Using query statement directly without being defined in mapping xml files.

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
targets - object of class which is matched with specified table in mapping xml files. is the List type of Object.
Returns:
an array of the number of rows affected by each statement
Throws:
QueryServiceException - if there is any problem issuing the update

create

int create(Object obj)
           throws QueryServiceException
Execute INSERT query, Using object, which class is matched with table by mapping xml files.

Parameters:
obj - object of class which is matched with specified table in mapping xml files.
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

create

int create(String queryId,
           Object[] values)
           throws QueryServiceException
Execute INSERT query, Using given queryId which defined in mapping xml files.

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

createBySQL

int createBySQL(String sql,
                String[] types,
                Object[] values)
                throws QueryServiceException
Execute INSERT query, Using query statement directly without being defined in mapping xml files.

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
values - a set of variable for executing query
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

execute

Map execute(String queryId,
            Map values)
            throws QueryServiceException
Execute an sql call using a CallableStatement

Parameters:
queryId - identifier of query statement to execute
values - a key-value set of variable for executing query
Returns:
Map of extracted out parameters
Throws:
QueryServiceException - if there is any problem issuing the execute

execute

Map execute(String queryId,
            Map values,
            int pageIndex)
            throws QueryServiceException
Execute an SELECT sql call using a CallableStatement which defined in mapping xml files. Returned results which find by condition and belong to specified page. Caution!. Not supported by some DBMS (e.g. Oracle 8i)

Parameters:
queryId - identifier of query statement to execute
values - a key-value set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
Returns:
Map of extracted out parameters
Throws:
QueryServiceException - if there is any problem issuing the execute

execute

Map execute(String queryId,
            Map values,
            int pageIndex,
            int pageSize)
            throws QueryServiceException
Execute an SELECT sql call using a CallableStatement which defined in mapping xml files. Returned results which find by condition and belong to specified page. Caution!. Not supported by some DBMS (e.g. Oracle 8i)

Parameters:
queryId - identifier of query statement to execute
values - a key-value set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
pageSize - page size which expected to be displayed per page (pageSize > 0)
Returns:
Map of extracted out parameters
Throws:
QueryServiceException - if there is any problem issuing the execute

executeBySQL

Map executeBySQL(String sql,
                 String[] types,
                 String[] names,
                 String[] bindings,
                 Map values)
                 throws QueryServiceException
Execute an Sql call using a CallableStatement

Parameters:
sql - callable statement to execute
types - a set of variable type for executing query
names - a set of variable name for executing query
bindings - a set of variable in-out type for executing query
values - a key-value set of variable for executing query
Returns:
Map of extracted out parameters
Throws:
QueryServiceException - if there is any problem issuing the execute

executeBySQL

Map executeBySQL(String sql,
                 String[] types,
                 String[] names,
                 String[] bindings,
                 Map values,
                 int pageIndex,
                 int pageSize)
                 throws QueryServiceException
Execute an Sql call using a CallableStatement

Parameters:
sql - callable statement to execute
types - a set of variable type for executing query
names - a set of variable name for executing query
bindings - a set of variable in-out type for executing query
values - a key-value set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
pageSize - page size which expected to be displayed per page (pageSize > 0)
Returns:
Map of extracted out parameters
Throws:
QueryServiceException - if there is any problem issuing the execute

find

Collection find(Object obj)
                throws QueryServiceException
Execute a SELECT query, Using object, which class is matched with table by mapping xml files. Returned a result which find by Primary key.

Parameters:
obj - object of class which is matched with specified table in mapping xml files.
Returns:
result. The size of result is 1.
Throws:
QueryServiceException - if there is any problem executing the query

find

Collection find(String queryId,
                Object[] values)
                throws QueryServiceException
Execute a SELECT query, Using given queryId which defined in mapping xml files. Returned all results which find by condition

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
Returns:
all results. Never returns null; returns the empty collection if there were no results.
Throws:
Exception - if there is any problem executing the query
QueryServiceException

find

Collection find(String queryId,
                Object[] values,
                int pageIndex)
                throws QueryServiceException
Execute a SELECT query, Using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page.

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
Returns:
results. The size of result is same as page size defined mapping xml files.
Throws:
QueryServiceException - if there is any problem executing the query

find

Collection find(String queryId,
                Object[] values,
                int pageIndex,
                int pageSize)
                throws QueryServiceException
Execute a SELECT query, Using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page.

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
pageSize - page size which expected to be displayed per page (pageSize > 0)
Returns:
results. The size of result is same as pagesize defined mapping xml files.
Throws:
QueryServiceException - if there is any problem executing the query

findBySQL

Collection findBySQL(String sql,
                     String[] types,
                     Object[] values)
                     throws QueryServiceException
Execute a SELECT query, Using query statement directly without being defined in mapping xml files. Returned all results which find by condition

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
values - a set of variable for executing query
Returns:
all results. Never returns null; returns the empty collection if there were no results.
Throws:
QueryServiceException - if there is any problem executing the query

findBySQL

Collection findBySQL(String sql,
                     String[] types,
                     Object[] values,
                     int pageIndex,
                     int pageSize)
                     throws QueryServiceException
Execute a SELECT query, Using query statement directly without being defined in mapping xml files. Returned results which find by condition and belong to specified page.

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
pageSize - page size which expected to be displayed per page (pageSize > 0)
Returns:
results. The size of result is same as pageSize.
Throws:
QueryServiceException - if there is any problem executing the query

findBySQLWithRowCount

Map findBySQLWithRowCount(String sql,
                          String[] types,
                          Object[] values)
                          throws QueryServiceException
Execute a SELECT query, Using query statement directly without being defined in mapping xml files. Returned all results which find by condition

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
values - a set of variable for executing query
Returns:
results. Never returns null; returns the empty collection if there were no results. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

findBySQLWithRowCount

Map findBySQLWithRowCount(String sql,
                          String[] types,
                          Object[] values,
                          int pageIndex,
                          int pageSize)
                          throws QueryServiceException
Execute a SELECT query, Using query statement directly without being defined in mapping xml files. Returned results which find by condition and belong to specified page.

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
pageSize - page size which expected to be displayed per page (pageSize > 0)
Returns:
results. The size of result is same as pageSize. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

findWithColInfo

Map findWithColInfo(String queryId,
                    Object[] values)
                    throws QueryServiceException
Execute a SELECT query, using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page (pageIndex = 0)

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
Returns:
results. The size of result is same as length of result which defined a specified query. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

findWithColInfo

Map findWithColInfo(String queryId,
                    Object[] values,
                    int pageIndex)
                    throws QueryServiceException
Execute a SELECT query, using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
Returns:
results. The size of result is same as length of result which defined a specified query. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

findWithColInfo

Map findWithColInfo(String queryId,
                    Object[] values,
                    int pageIndex,
                    int pageSize)
                    throws QueryServiceException
Execute a SELECT query, using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
pageSize - page size which expected to be displayed per page (pageSize > 0)
Returns:
results. The size of result is same as length of result which defined a specified query. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

findWithRowCount

Map findWithRowCount(String queryId,
                     Object[] values)
                     throws QueryServiceException
Execute a SELECT query, using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page (pageIndex = 0)

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
Returns:
results. The size of result is same as length of result which defined a specified query. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

findWithRowCount

Map findWithRowCount(String queryId,
                     Object[] values,
                     int pageIndex)
                     throws QueryServiceException
Execute a SELECT query, using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page.

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
Returns:
results. The size of result is same as length of result which defined a specified query. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

findWithRowCount

Map findWithRowCount(String queryId,
                     Object[] values,
                     int pageIndex,
                     int pageSize)
                     throws QueryServiceException
Execute a SELECT query, using given queryId which defined in mapping xml files. Returned results which find by condition and belong to specified page.

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
pageIndex - page number which expected to be displayed (pageIndex > 0)
pageSize - page size which expected to be displayed per page (pageSize > 0)
Returns:
results. The size of result is same as pageSize. The result value includes the query execution result handled by paging and the total result number. And takes values as IQueryService.LIST, IQueryService.COUNT.
Throws:
QueryServiceException - if there is any problem executing the query

remove

int remove(Object obj)
           throws QueryServiceException
Execute DELETE query, using object, which class is matched with table by mapping xml files.

Parameters:
obj - object of class which is matched with specified table in mapping xml files.
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

remove

int remove(String queryId,
           Object[] values)
           throws QueryServiceException
Execute DELETE query, using given queryId which defined in mapping xml files.

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

removeBySQL

int removeBySQL(String sql,
                String[] types,
                Object[] values)
                throws QueryServiceException
Execute DELETE query, using query statement directly without being defined in mapping xml files.

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
values - a set of variable for executing query
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

update

int update(Object obj)
           throws QueryServiceException
Execute UPDATE query, using object, which class is matched with table by mapping xml files.

Parameters:
obj - object of class which is matched with specified table in mapping xml files.
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

update

int update(String queryId,
           Object[] values)
           throws QueryServiceException
Execute UPDATE query, using given queryId which defined in mapping xml files.

Parameters:
queryId - identifier of query statement to execute
values - a set of variable for executing query
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

updateBySQL

int updateBySQL(String sql,
                String[] types,
                Object[] values)
                throws QueryServiceException
Execute UPDATE query, using query statement directly without being defined in mapping xml files.

Parameters:
sql - query statement.
types - is matched with input parameters. A type must belong to fields defined java.sql.Types package
values - a set of variable for executing query
Returns:
the number of rows affected
Throws:
QueryServiceException - if there is any problem executing the query

countQuery

int countQuery()
Count all queries which defined in mapping xml files.

Returns:
number of queries

getQueryMap

Map getQueryMap()
                throws QueryServiceException
Find all query list which defined in mapping xml files.

Returns:
map of queryId and query statement.
Throws:
QueryServiceException - if there is any problem making mapping map

getQueryParams

ArrayList getQueryParams(String queryId)
                         throws QueryServiceException
Find parameters for specified query.

Returns:
ArrayList consist of param type and name
Throws:
QueryServiceException - if there is any problem find parameters.

getQueryServiceJdbcTemplate

JdbcTemplate getQueryServiceJdbcTemplate()
Get JdbcTemplate which QueryService uses

Returns:
JdbcTemplate which set in configuration file

getStatement

String getStatement(String queryId)
                    throws QueryServiceException
Find specified query statement which queryId equal to input parameter.

Parameters:
queryId - query id which defined a mapping xml file
Returns:
query statement
Throws:
QueryServiceException - if there is any problem find sql

getQueryInfo

IQueryInfo getQueryInfo(String queryId)
Find specified query information which queryId equal to input parameter.

Parameters:
queryId - query id which defined a mapping xml file
Returns:
query information

Anyframe Core

Copyright © 2008-2009 Samsung SDS. All Rights Reserved.