我在ContestDAO接口中有个这么个方法
public List<ContestForm> getContestSelect(ContestForm contestform)
我现在想在ContestDaoSupport这个类中实现这个方法
我怎么写IDE都提示错误
我想在这个实例中实现查询表contest中的title字段
根据表contest中的course_id字段
查询course表中的college_id字段
public interface ContestDAO {

public List<ContestForm> getContest() throws ApplicationException;

//查询试卷
public List<ContestForm> getContestSelect(ContestForm contestform) throws ApplicationException;
    //删除试卷
public void getContestDelete(int contest_id) throws ApplicationException;
//删除确认
public List<ContestForm> checkDelete(ContestForm contestform) throws ApplicationException;

}
public abstract class ContestDaoSupport extends HibernateDaoSupport 
implements ContestDAO{private TransactionTemplate transactionTemplate; 
    //使用注入的TransactionManager生成一个transactionTemplate实例
    public void setTransactionManager(PlatformTransactionManager transactionManager) { 
        this.transactionTemplate = new TransactionTemplate(transactionManager); 
    } 
    //查询试卷
    @SuppressWarnings("unchecked")
public List<ContestForm> getContestSelect(ContestForm contestform){
     //TransactionDefinition.PROPAGATION_REQUIRED表示把getContestSelect方法放入事务管理中
     transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); 
        Object result=transactionTemplate.execute(new TransactionCallback() { 
                public Object doInTransaction(TransactionStatus status) {

                 return status;
                }
                });
return (List<ContestForm>) contestform;
    }      
}

解决方案 »

  1.   

    现在没提示错误了
    但是方法不知道对不对
    @SuppressWarnings("unchecked") 
    这个对类有什么影响能不能也帮解释下
      

  2.   

    public class PageUtil { private int[] pageRecordCountList = {10, 20, 50}; private int pageRecordCount = 10; private int currentPageNo = 1; private int recordCount = 0; private int pageNoCount = 1; private int pageStartIndex = 1; private int pageEndIndex = 1; private int firstPageNo = 1; private int prePageNo = 1; private int nextPageNo = 1; private int lastPageNo = 1; private List<Map<String, String>> resultList;

    public PageUtil(int pageRecordCount, int currentPageNo, int recordCount, List<Map<String, String>> resultList) { this.pageRecordCount = pageRecordCount;
    this.currentPageNo = currentPageNo;
    this.recordCount = recordCount;
    this.resultList = resultList; if (recordCount % pageRecordCount == 0) {
    this.pageNoCount = recordCount / pageRecordCount;
    } else {
    this.pageNoCount = recordCount / pageRecordCount + 1;
    }
    this.lastPageNo = this.pageNoCount; int baseRecordCount = pageRecordCount * (currentPageNo - 1);
    this.pageStartIndex = baseRecordCount + 1;
    this.pageEndIndex = baseRecordCount + resultList.size(); if (this.currentPageNo > 1) {
    this.prePageNo = this.currentPageNo -1;
    }
    if (this.currentPageNo == this.lastPageNo) {
    this.nextPageNo = this.lastPageNo;
    } else {
    this.nextPageNo = this.currentPageNo + 1;
    }
    } public Object[] getPageSizeIndexs() { List<String> result = new ArrayList<String>(pageRecordCountList.length);
    for (int i = 0; i < pageRecordCountList.length; i++) {
    result.add(String.valueOf(pageRecordCountList[i]));
    }
    Object[] indexs = (result.toArray());
    return indexs;
    }

    public Object[] getPageNoIndexs() { List<String> result = new ArrayList<String>(pageNoCount);
    for (int i = 0; i < pageNoCount; i++) {
    result.add(String.valueOf(i + 1));
    }
    Object[] indexs = (result.toArray());
    return indexs;
    } /**
     * @return the pageRecordCountList
     */
    public int[] getPageRecordCountList() {
    return this.pageRecordCountList;
    } /**
     * @param pageRecordCountList the pageRecordCountList to set
     */
    public void setPageRecordCountList(int[] pageRecordCountList) {
    this.pageRecordCountList = pageRecordCountList;
    } /**
     * @return the pageRecordCount
     */
    public int getPageRecordCount() {
    return this.pageRecordCount;
    } /**
     * @param pageRecordCount the pageRecordCount to set
     */
    public void setPageRecordCount(int pageRecordCount) {
    this.pageRecordCount = pageRecordCount;
    } /**
     * @return the currentPageNo
     */
    public int getCurrentPageNo() {
    return this.currentPageNo;
    } /**
     * @param currentPageNo the currentPageNo to set
     */
    public void setCurrentPageNo(int currentPageNo) {
    this.currentPageNo = currentPageNo;
    } /**
     * @return the recordCount
     */
    public int getRecordCount() {
    return this.recordCount;
    } /**
     * @param recordCount the recordCount to set
     */
    public void setRecordCount(int recordCount) {
    this.recordCount = recordCount;
    } /**
     * @return the pageNoCount
     */
    public int getPageNoCount() {
    return this.pageNoCount;
    } /**
     * @param pageNoCount the pageNoCount to set
     */
    public void setPageNoCount(int pageNoCount) {
    this.pageNoCount = pageNoCount;
    } /**
     * @return the pageStartIndex
     */
    public int getPageStartIndex() {
    return this.pageStartIndex;
    } /**
     * @param pageStartIndex the pageStartIndex to set
     */
    public void setPageStartIndex(int pageStartIndex) {
    this.pageStartIndex = pageStartIndex;
    } /**
     * @return the pageEndIndex
     */
    public int getPageEndIndex() {
    return this.pageEndIndex;
    } /**
     * @param pageEndIndex the pageEndIndex to set
     */
    public void setPageEndIndex(int pageEndIndex) {
    this.pageEndIndex = pageEndIndex;
    } /**
     * @return the firstPageNo
     */
    public int getFirstPageNo() {
    return this.firstPageNo;
    } /**
     * @param firstPageNo the firstPageNo to set
     */
    public void setFirstPageNo(int firstPageNo) {
    this.firstPageNo = firstPageNo;
    } /**
     * @return the prePageNo
     */
    public int getPrePageNo() {
    return this.prePageNo;
    } /**
     * @param prePageNo the prePageNo to set
     */
    public void setPrePageNo(int prePageNo) {
    this.prePageNo = prePageNo;
    } /**
     * @return the nextPageNo
     */
    public int getNextPageNo() {
    return this.nextPageNo;
    } /**
     * @param nextPageNo the nextPageNo to set
     */
    public void setNextPageNo(int nextPageNo) {
    this.nextPageNo = nextPageNo;
    } /**
     * @return the lastPageNo
     */
    public int getLastPageNo() {
    return this.lastPageNo;
    } /**
     * @param lastPageNo the lastPageNo to set
     */
    public void setLastPageNo(int lastPageNo) {
    this.lastPageNo = lastPageNo;
    } /**
     * @return the resultList
     */
    public List<Map<String, String>> getResultList() {
    return this.resultList;
    } /**
     * @param resultList the resultList to set
     */
    public void setResultList(List<Map<String, String>> resultList) {
    this.resultList = resultList;
    }
    这是个分页的方法
    最好能帮我解释下根据这个分页写个aciton传到JSP里
    谢谢
    每个问题100分
    今天刚发的帖子加不了明天加
    结贴率100%
      

  3.   

    现在程序没错误了
    但是不知道怎么用HQL进行双表查询
    最后结果如何实现分页
      

  4.   

    现在程序没错误了
    但是不知道怎么用HQL进行双表查询
    最后结果如何实现分页
      

  5.   

    你是用hibernate吧,其实你的业务逻辑比较简单,用jdbc很容易搞定。
      

  6.   

    @SuppressWarnings("unchecked") 
    屏蔽某些编译时的警告信息 
    在强制类型转换的时候编译器会给出警告 
    就不会警告了
    ----------------------------
      

  7.   

    PageUtil 只是辅助分页的,不能实现正真的分页!
    传入的参数
    pageRecordCount //每页记录的条数
    currentPageNo   //当前页码
    recordCount     //总共记录数
    resultList     //分页集
    通过这个类你可以拿到上一页、下一页等参数,正真的分页查询还要得写HQL
      

  8.   

    兄弟,用hql语句进行双表甚至多表连接查询的前提是要配置表对象之间的关系。要用到orm //hql是个多表连接查询的例句。Users 是用户对象,positions是职位表的配置对象,它是Users对象的一个属性
    String hql = "select f.funId from Users u inner join u.positions as r " +
    "inner join r.functions as f where u.userId=:uid";
      

  9.   

    这是我分页的一个方法
    //current是显示第几页,pageSize是每页显示多少条记录
    public List query(final String hql, final Map<String, Object> map,final int current,final int pageSize)throws CommonException
    {
    return this.getHibernateTemplate().executeFind(new HibernateCallback(){ public Object doInHibernate(Session session) throws HibernateException, SQLException {
    Query query = session.createQuery(hql);
    if(map!=null)
    {
    for(String s : map.keySet())
    {
    query.setParameter(s, map.get(s));
    }
    }
    query.setFirstResult((current-1)*pageSize);//
    query.setMaxResults(pageSize);
    return query.list();
    }

    });
    }
      

  10.   

    我写的是基于ssh框架的,你没用到spring吧?看你的事务管理就知道了
      

  11.   

    知道在FORM类里还有对应的HBM.XML里都配置了
      

  12.   

    知道相应的hbm.xml和FORM类都已经配置妥当
      

  13.   


    那这个hql例句对你理解有帮助么?
      

  14.   

    能不能给我发下这个基于SSH框架技术的工程啊
    我想参考下
    有些引入也不能用
      

  15.   

    发了好几次
    [email protected]