roadquery.java
来自「Java的框架」· Java 代码 · 共 139 行
JAVA
139 行
package mcaps.apps.prrm.roaddefect.dao.jdbc.query;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import mcap.core.base.dao.jdbc.SQLQuery;
import mcap.core.base.dao.util.SortOrder;
import mcaps.apps.prrm.roaddefect.dao.util.RoadField;
import mcaps.apps.prrm.roaddefect.model.Road;
import mcaps.apps.prrm.util.TableNameConstants;
/**
* The class that extends the SQLQuery class to customize
* the query for road table.
*
* @author jov
* @date Sept 23, 2005
* @version 1.0.1.0
*/
public class RoadQuery extends SQLQuery {
/**
* The default constructor that accepts datasource and
* provides the contact table name to initialize the super
* class constructor.
* @param ds the datasource object
*/
public RoadQuery(DataSource ds) {
super(ds,TableNameConstants.ROADMAP_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 RoadQuery(DataSource ds, int sortFieldIdx, SortOrder order) {
super(ds, TableNameConstants.ROADMAP_TABLENAME, sortFieldIdx, 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 RoadQuery(DataSource ds, int[] sortFieldIdxArray, SortOrder[] sortOrderArray) {
super(ds, TableNameConstants.ROADMAP_TABLENAME, sortFieldIdxArray, 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 RoadQuery(DataSource ds, String whereClause, int[] paramTypes){
super(ds, TableNameConstants.ROADMAP_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 RoadQuery(DataSource ds, String whereClause,
int[] paramTypes, int sortColIdx,
SortOrder order) {
super(ds, TableNameConstants.ROADMAP_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 RoadQuery(DataSource ds, String whereClause,
int[] paramTypes, int[] sortFieldIdxArray,
SortOrder[] sortOrderArray) {
super(ds, TableNameConstants.ROADMAP_TABLENAME, whereClause, paramTypes, sortFieldIdxArray, 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;
Road road = new Road();
road.setId(new Integer(rs.getInt(RoadField.FIELDS[i++])));
road.setName(rs.getString(RoadField.FIELDS[i++]));
road.setBbox(rs.getString("bbox"));
return road;
}
/* (non-Javadoc)
* @see mcap.prrm.base.dao.jdbc.SQLQuery#getSelectFieldsName()
*/
protected String[] getSelectFieldsName(){
return RoadField.FIELDS;
}
/* (non-Javadoc)
* @see mcap.prrm.base.dao.jdbc.SQLQuery#getSelect()
*/
protected String getSelect(){
return "SELECT ";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?