roadinspectionquery.java

来自「Java的框架」· Java 代码 · 共 142 行

JAVA
142
字号
package mcaps.apps.prrm.roadinspection.dao.jdbc.query;

import java.sql.ResultSet;
import java.sql.SQLException;

import javax.sql.DataSource;

import mcaps.apps.prrm.roadinspection.dao.util.RoadInspectionField;
import mcaps.apps.prrm.roadinspection.model.RoadInspection;
import mcap.core.base.dao.jdbc.SQLQuery;
import mcap.core.base.dao.util.SortOrder;
import mcaps.apps.prrm.util.TableNameConstants;

/**
 * The class that extends the SQLQuery class to customize
 * the query for road inspection.
 * 
 * @author jov
 * @date Oct 12, 2005
 * @version 1.0.1.0
 */
public class RoadInspectionQuery extends SQLQuery {

	
	/**
	 * The default constructor that accepts datasource and 
	 * provides the contact table name to initialize the super
	 * class constructor.
	 * @param ds
	 */
	public RoadInspectionQuery(DataSource ds) {
		super(ds,TableNameConstants.ROADINSPECTION_TABLENAME);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like sort field index and sort order 
	 * and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param sortColumnIdx the index of the field in which used as sort column
	 * @param order the sort order
	 */
	public RoadInspectionQuery(DataSource ds, int sortColumnIdx, SortOrder order) {
		super(ds, TableNameConstants.ROADINSPECTION_TABLENAME, sortColumnIdx, order);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like sort field index array and sort order array
	 * and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param sortFieldIdxArray the array off sort field index
	 * @param orderArray the array of the sort order for the sort fields
	 */
	public RoadInspectionQuery(DataSource ds, int[] sortColumnIdxArray, SortOrder[] sortOrderArray) {
		super(ds, TableNameConstants.ROADINSPECTION_TABLENAME, sortColumnIdxArray, sortOrderArray);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like where clause and param types of the where
	 * clause parameters and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param whereClause where clause to refine the query
	 * @param paramTypes the array of parameter types
	 */
	public RoadInspectionQuery(DataSource ds, String whereClause, int[] paramTypes){
		super(ds, TableNameConstants.ROADINSPECTION_TABLENAME, whereClause, paramTypes);
	}
	
	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like where clause, param types of the where
	 * clause parameters, sort column index, sort order and provides 
	 * table name to initialize the super class constructor.
	 * @param ds the datasource object
	 * @param whereClause where clause to refine the query
	 * @param paramTypes the array of parameter types
	 * @param sortFieldIdx the sort field index
	 * @param order the sort order
	 */
	public RoadInspectionQuery(DataSource ds, String whereClause, 
													int[] paramTypes, int sortColIdx,
													SortOrder order) {
		super(ds, TableNameConstants.ROADINSPECTION_TABLENAME, whereClause, paramTypes, sortColIdx, order);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like where clause and param types of the where
	 * clause parameters, sort field index array, sort order
	 * array and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param whereClause where clause to refine the query
	 * @param paramTypes the array of parameter types
	 * @param sortFieldIdxArray the array of sort field index
	 * @param orderArray the array of sort order
	 */
	public RoadInspectionQuery(DataSource ds, String whereClause, 
													int[] paramTypes, int[] sortColumnIdxArray, 
													SortOrder[] sortOrderArray) {
		super(ds, TableNameConstants.ROADINSPECTION_TABLENAME, whereClause, paramTypes, sortColumnIdxArray, sortOrderArray);
	}

	/* (non-Javadoc)
	 * @see org.springframework.jdbc.object.MappingSqlQuery#mapRow(java.sql.ResultSet, int)
	 */
	protected Object mapRow(ResultSet rs, int rowNum) throws SQLException {
		int i = 0;
		RoadInspection roadInspection = new RoadInspection();
		roadInspection.setId(new Integer(rs.getInt(RoadInspectionField.FIELDS[i++])));
		roadInspection.setRoadDefectId(new Integer(rs.getInt(RoadInspectionField.FIELDS[i++])));
		roadInspection.setTaskId(new Integer(rs.getInt(RoadInspectionField.FIELDS[i++])));
		roadInspection.setDefectType(rs.getString(RoadInspectionField.FIELDS[i++]));
		roadInspection.setDefectDetail(rs.getString(RoadInspectionField.FIELDS[i++]));
		roadInspection.setRoadName(rs.getString(RoadInspectionField.FIELDS[i++]));
		roadInspection.setLocation(rs.getString(RoadInspectionField.FIELDS[i++]));
		roadInspection.setSeverity(rs.getString(RoadInspectionField.FIELDS[i++]));
		roadInspection.setSummary(rs.getString(RoadInspectionField.FIELDS[i++]));
		roadInspection.setSolution(rs.getString(RoadInspectionField.FIELDS[i++]));
		roadInspection.setRepairRequired(new Boolean(rs.getBoolean(RoadInspectionField.FIELDS[i++])));
		roadInspection.setCreationTime(rs.getTimestamp(RoadInspectionField.FIELDS[i++]));
		roadInspection.setLastModifiedTime(rs.getTimestamp(RoadInspectionField.FIELDS[i++]));
		return roadInspection;
	}
	
	/* (non-Javadoc)
	 * @see mcapss.prrm.base.dao.jdbc.SQLQuery#getSelectFieldsName()
	 */
	protected String[] getSelectFieldsName(){
		return RoadInspectionField.FIELDS;		
	}

	


}

⌨️ 快捷键说明

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