package com.finegold2.common.impl;
import java.sql.SQLException;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.aptech.query.HibernateQueryHql;
import com.aptech.query.HqlExecute;
import com.aptech.query.QueryException;
import com.finegold2.common.ICommon;
import com.finegold2.exception.CommonException;
public class Common<POJO> extends HibernateDaoSupport implements ICommon<POJO>{
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#insert(POJO)
*/
public void insert(POJO pojo)throws CommonException{
try {
this.getHibernateTemplate().save(pojo);
} catch (DataAccessException e) {
e.printStackTrace();
throw new CommonException(e);
}
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#delete(java.lang.Class, int)
*/
public void delete(Class clazz,int id)throws CommonException{
try {
POJO pojo=(POJO) this.getHibernateTemplate().load(clazz, id);
this.getHibernateTemplate().delete(pojo);
} catch (DataAccessException e) {
e.printStackTrace();
throw new CommonException(e);
}
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#update(POJO)
*/
public void update(POJO pojo)throws CommonException{
try {
this.getHibernateTemplate().update(pojo);
} catch (DataAccessException e) {
e.printStackTrace();
throw new CommonException(e);
}
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#getfindByid(java.lang.Class, int)
*/
public POJO getfindByid(Class clazz,int id)throws CommonException{
try {
POJO pojo=(POJO) this.getHibernateTemplate().get(clazz, id);
return pojo;
} catch (DataAccessException e) {
e.printStackTrace();
throw new CommonException(e);
}
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#loadfindByid(java.lang.Class, int)
*/
public POJO loadfindByid(Class clazz,int id)throws CommonException{
try {
POJO pojo=(POJO)this.getHibernateTemplate().load(clazz, id);
return pojo;
} catch (DataAccessException e) {
e.printStackTrace();
throw new CommonException(e);
}
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#queryPojo(java.lang.Class)
*/
public List queryPojo(final Class clazz)throws CommonException{
try {
return this.getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
return session.createQuery("form "+clazz.getSimpleName()).list();
}});
} catch (DataAccessException e) {
e.printStackTrace();
throw new CommonException(e);
}
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#currencyQuery(com.aptech.query.HqlExecute)
*/
public List currencyQuery(final HqlExecute hqlexe) throws CommonException {
try {
return this.getHibernateTemplate().executeFind(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
try {
return hqlexe.execute(session);
} catch (QueryException e) {
e.printStackTrace();
return null;
}
}
});
} catch (DataAccessException e) {
e.printStackTrace();
throw new CommonException(e);
}
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#getSizeUnCondition(java.lang.Class)
*/
public int getSizeUnCondition(final Class clazz) throws CommonException {
return Integer.parseInt(this.getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
HibernateQueryHql hql = new HibernateQueryHql();
try {
hql.addEntity(clazz, "a");
hql.setSelect("count(*)");
HqlExecute hqlexe = new HqlExecute(hql);
List lst = hqlexe.execute(session);
return lst.get(0);
} catch (QueryException e) {
e.printStackTrace();
throw new HibernateException(e);
}
}
}).toString());
}
/* (non-Javadoc)
* @see com.finegold2.common.impl.ICommon#getPageSize(java.lang.Class, int)
*/
public int[] getPageSize(Class clazz, int pagesize) throws CommonException {
int size = this.getSizeUnCondition(clazz);
return new int[] {
size % pagesize == 0 ? size / pagesize : size / pagesize + 1,
size };
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ajax分页查询完美示例
共96个文件
class:25个
java:22个
xml:15个
3星 · 超过75%的资源 需积分: 9 44 下载量 16 浏览量
2009-01-04
21:55:23
上传
评论
收藏 1.67MB RAR 举报
温馨提示
ajax分页查询完美示例.rar ajax分页查询完美示例.rar ajax分页查询完美示例.rar
资源推荐
资源详情
资源评论
收起资源包目录
ajax分页查询完美示例.rar (96个子文件)
pdda_db.sql 2KB
PDDA2
.project 2KB
.settings
org.eclipse.core.resources.prefs 88B
pdda_db.sql 2KB
.mymetadata 288B
WebRoot
WEB-INF
struts-tiles.tld 8KB
.struts-config.mex 943B
web.xml 1KB
struts-config.xml 1024B
struts-bean.tld 9KB
spring-form.tld 51KB
struts-nested.tld 70KB
struts-html.tld 72KB
spring.tld 13KB
struts-logic.tld 14KB
validator-rules.xml 13KB
lib
commons-logging.jar 33KB
commons-digester.jar 147KB
commons-fileupload.jar 19KB
mysql.jar 464KB
commons-beanutils.jar 160KB
antlr.jar 344KB
struts.jar 474KB
commons-validator.jar 74KB
lzhquery.jar 9KB
jakarta-oro.jar 62KB
classes
com
finegold2
dao
IBookListDao.class 407B
IVoucherDao.class 798B
impl
BookListDao.class 3KB
VoucherDao.class 4KB
action
BookAction.class 4KB
VoucherAction.class 3KB
exception
DaoException.class 744B
ServiceException.class 756B
CommonException.class 749B
vo
VoucherVo.class 3KB
BookListVo.class 3KB
form
DataMapForm.class 3KB
common
impl
Common$2.class 1KB
Common$1.class 1KB
Common$3.class 2KB
Common.class 4KB
ICommon.class 819B
service
IVoucherService.class 624B
IBookService.class 682B
impl
VoucherService.class 3KB
BookService.class 3KB
pojo
Vouchertype.hbm.xml 662B
Bookslist.hbm.xml 2KB
Vouchertype.class 924B
Voucher.class 3KB
Voucher.hbm.xml 2KB
Bookslist.class 3KB
yourcompany
struts
MyRequestProcessor.class 910B
ApplicationResources.properties 88B
actions.xml 446B
applicationContext.xml 3KB
hibernate.cfg.xml 1KB
index.jsp 834B
META-INF
MANIFEST.MF 39B
voucher.jsp 1009B
lendinfo.jsp 14KB
err.jsp 860B
.myeclipse
src
com
finegold2
dao
IVoucherDao.java 892B
impl
BookListDao.java 2KB
VoucherDao.java 4KB
IBookListDao.java 531B
action
BookAction.java 4KB
VoucherAction.java 2KB
exception
CommonException.java 521B
ServiceException.java 542B
DaoException.java 523B
vo
BookListVo.java 2KB
VoucherVo.java 2KB
form
DataMapForm.java 2KB
common
ICommon.java 921B
impl
Common.java 5KB
service
IVoucherService.java 735B
impl
VoucherService.java 3KB
BookService.java 2KB
IBookService.java 618B
pojo
Vouchertype.hbm.xml 662B
Bookslist.hbm.xml 2KB
Voucher.hbm.xml 2KB
Voucher.java 2KB
Vouchertype.java 684B
Bookslist.java 2KB
yourcompany
struts
MyRequestProcessor.java 649B
ApplicationResources.properties 88B
actions.xml 446B
applicationContext.xml 3KB
hibernate.cfg.xml 1KB
.mystrutsdata 262B
.springBeans 320B
.classpath 2KB
.myhibernatedata 458B
共 96 条
- 1
资源评论
- weixin_418154262018-10-21不是想要的资料,
- 梦洋_梦2014-05-26效果不错,很好用
penchy1220
- 粉丝: 1
- 资源: 30
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功