我在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;
}
}
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;
}
}
解决方案 »
- struts2+uploadify上传时,为什么后台得到我文件类数据型全部都是application/octet-stream?
- struts2 访问拦截配置疑问
- 怎么处理Hibernate里的date类型?
- spring配置事物的5种方法,任意一种都能实现全部功能吧
- 求助编程题
- eclipse debug java程序,如何看内存是否溢出
- hibernate的配置文件属性:connection.autocommit=true有哪些缺点?为何不建议使用true呢????
- jboss3.2.2,db27.2中当连接用户名和数据库里模式名不一样时该怎么办?
- Echo1.0正式版发布了~~~~~
- 关于邮箱验证修改密码的问题
- Spring拦截器被拦截的bean不实现接口可以吗?
- 网上下了个简单的dwr的页面聊天程序,一直报错
但是方法不知道对不对
@SuppressWarnings("unchecked")
这个对类有什么影响能不能也帮解释下
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%
但是不知道怎么用HQL进行双表查询
最后结果如何实现分页
但是不知道怎么用HQL进行双表查询
最后结果如何实现分页
屏蔽某些编译时的警告信息
在强制类型转换的时候编译器会给出警告
就不会警告了
----------------------------
传入的参数
pageRecordCount //每页记录的条数
currentPageNo //当前页码
recordCount //总共记录数
resultList //分页集
通过这个类你可以拿到上一页、下一页等参数,正真的分页查询还要得写HQL
String hql = "select f.funId from Users u inner join u.positions as r " +
"inner join r.functions as f where u.userId=:uid";
//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();
}
});
}
那这个hql例句对你理解有帮助么?
我想参考下
有些引入也不能用
[email protected]