sqlmapquerydao.java

来自「esri的ArcGIS Server超级学习模板程序(for java)」· Java 代码 · 共 88 行

JAVA
88
字号
package com.esri.solutions.jitk.personalization.dao;

import java.util.*;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.dao.DataAccessException;

/**
* @author Susan Herdina
* @version 1.0
* @created 05-Nov-2007 10:29:29 AM
* 
* This class implements the IQueryDAO and provides functionality to read and write 
* Query Records to and from the database.
*/
public class SqlMapQueryDAO extends SqlMapClientDaoSupport implements IQueryDAO {

	public void insert(QueryRecord query)
			throws PersonalizationDAOException {
		try{
			query.setTimeModified(new java.sql.Timestamp(System.currentTimeMillis()));
			getSqlMapClientTemplate().insert("insertQuery", query);	
		}
		catch(DataAccessException e){
			throw new PersonalizationDAOException( e );
		}		
	}

	public List<QueryInfoRecord> selectAll(Criteria criteria)
			throws PersonalizationDAOException {
		try{
			return getSqlMapClientTemplate().queryForList("selectAllQueries", criteria);
		}
		catch(DataAccessException e){
			throw new PersonalizationDAOException( e );
		}
	}

	public int selectAllCount(Criteria criteria) throws PersonalizationDAOException {
		try{
			return Integer.parseInt(getSqlMapClientTemplate().queryForObject("selectCountQueries", criteria).toString());
		}
		catch(DataAccessException e){
			throw new PersonalizationDAOException( e );
		}
	}
	
	public List<QueryInfoRecord> selectPage(Criteria criteria, PageInfo pageInfo)
			throws PersonalizationDAOException {
		try{
			int skipResults = (pageInfo.getPageIndex() * pageInfo.getPageSize());
			return getSqlMapClientTemplate().queryForList("selectPageQueries", criteria, skipResults, pageInfo.getPageSize());
		}
		catch(DataAccessException e){
			throw new PersonalizationDAOException( e );
		}
	}	
	
	public QueryRecord selectOne(String id)
			throws PersonalizationDAOException {
		try{
			return (QueryRecord)getSqlMapClientTemplate().queryForObject("selectOneQuery", id);
		}
		catch(DataAccessException e){
			throw new PersonalizationDAOException( e );
		}
	}	

	public void update(QueryRecord query)
			throws PersonalizationDAOException {
		try{
			query.setTimeModified(new java.sql.Timestamp(System.currentTimeMillis()));
			getSqlMapClientTemplate().update("updateQuery", query);	
		}
		catch(DataAccessException e){
			throw new PersonalizationDAOException( e );
		}
	}
	
	public void delete(String id) throws PersonalizationDAOException {
		try{
			getSqlMapClientTemplate().delete("deleteQuery", id);
		}
		catch(DataAccessException e){
			throw new PersonalizationDAOException( e );
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?