//删除一个
public void deleteByInfoId(final String infoId) {
try {
this.getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
String hql = "delete "+getClazz().getName()+" where infoId = :infoId";
Query query = session.createQuery(hql);
query.setParameter("infoId", infoId);
return query.executeUpdate();
}
});
} catch (org.springframework.dao.DataAccessException e) {
// TODO Auto-generated catch block
throw new DataAccessException(e.getMessage(),e);
}
}
==============================================
批量删除
public void deleteExhibitionShowList(final List<String> list) {
// TODO Auto-generated method stub
try {
this.getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
String hql = "delete "+getClazz().getName()+" where showId in(:ids)";
Query query = session.createQuery(hql);
query.setParameterList("ids", list);
return query.executeUpdate();
}
});
} catch (org.springframework.dao.DataAccessException e) {
// TODO Auto-generated catch block
throw new DataAccessException(e.getMessage(),e);
}
}
//批量更新 日期
public void update(final List<String> list, final String state) {
// TODO Auto-generated method stub
try {
this.getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
String hql = "update "+getClazz().getName()+" set approveStateId = :state where showApplyId in(:ids)";
Query query = session.createQuery(hql);
query.setParameter("state", state);
query.setParameterList("ids", list);
return query.executeUpdate();
}
});
} catch (org.springframework.dao.DataAccessException e) {
// TODO Auto-generated catch block
throw new DataAccessException(e.getMessage(),e);
}
}
//分页查找
public WebPage getExhibitionShowList(Map map) {
// TODO Auto-generated method stub
StringBuffer count = new StringBuffer("select count(*) from "+this.getClazz().getName());
StringBuffer hql = new StringBuffer("from "+this.getClazz().getName());
StringBuffer where = new StringBuffer(" where 1=1 ");
List params = null;
int start = -1;
int limit = 0;
if(map != null){
params = new ArrayList();
if(map.get("exhibitionId") != null && !"".equals(map.get("exhibitionId"))){
where.append(" and exhibitionId = ? ");
params.add(map.get("exhibitionId"));
}
if(map.get("showName") != null && !"".equals(map.get("showName"))){
where.append(" and showName like ? ");
params.add("%"+map.get("showName")+"%");
}
if(dateStart!=null && !"".equals(dateStart)) {
hql.append(" and np.createDate >= ? ");
Date dateStartd=null;
try {
dateStartd=new SimpleDateFormat("yyyy-MM-dd").parse(dateStart);
} catch (Exception e) {
// TODO: handle exception
}
params.add(dateStartd);
}
if(dateEnd!=null && !"".equals(dateEnd)) {
hql.append(" and np.createDate < ? ");
Date dateEndd=null;
try {
dateEndd=new SimpleDateFormat("yyyy-MM-dd").parse(dateEnd);
} catch (Exception e) {
// TODO: handle exception
}
Calendar calendar=Calendar.getInstance();
calendar.clear();
calendar.setTime(dateEndd);
calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)+1);//让日期加1
params.add(calendar.getTime());
}
if(map.get("start") != null){
start = (Integer) map.get("start");
}
if(map.get("limit") != null){
limit = (Integer) map.get("limit");
}
count.append(where);
hql.append(where);
if(this.getOrderMap() == null){
hql.append(" order by entryDate desc");
}
else{
Map orderMap = this.getOrderMap();
hql.append(" order by "+orderMap.get("sort")+" "+orderMap.get("dir"));
}
}
if(params != null){
return this.findByPage(count.toString(), hql.toString(), params.toArray(), start, limit);
}
else{
return this.findByPage(count.toString(), hql.toString(), null, start, limit);
}
}
分享到:
相关推荐
DAOimpl(删除,查询)代码.pdf
NULL 博文链接:https://skywhsq1987.iteye.com/blog/1513734
因为这是本人亲自试用过的工具,自己感觉好牛逼啊,绝对的货真价实,mybatis反向生成工具,不会用的话本人可以教授使用,所以资源分偏高
mybatis的逆向工程代码 mybatis的逆向工程代码 mybatis的逆向工程代码
实体类entity:文档对象实体 action: 是struts中action层 主要处理表现层的东西 facade:只是一个门面模式(不起多大的作用)主要是... (**DAO是一个接口 每个这样的dao都有个它的实现类与它对应 -也就是**DAOImpl)
jsp+servlet+javaBean访问数据库的简单例子,但是类设置非常巧妙,大家注意。
DaoImpl, the C# DAO implementation class that implements the interface referred by DaoIntf. SqlMap, the IBatis.NET SQL mapping file that contains SQL statements used in the DaoImpl above.
其中我负责总体设计及协作交流管理模块的设计开发 技术要求:1、采用MVC+DAO模式设计开发,其中的VO包主要处理表字段,DAO包主要包括数据操作方法的声明,这些方法在DAOImpl包中实现。在DAO工厂模式的基础上,引入...
见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache.xml及web.xml的pageEhCacheFilter 4.MyBatis+Maven代码生成工具。见bin目录 5.作为项目或者技术研究的基础架构。必要的jar包依赖都已配置好,...
2.ssm模板实现:pojo,dao,daoimpl,service,serviceimpl,controller,各mapper.xml 代码自动生成, 3.配置文件自动生(含:spring,springMVC,mybatis,web.xml); 代码完美运行. 使用: 1.配置generator.xml(key):...
2.ssm模板实现:pojo,dao,daoimpl,service,serviceimpl,controller,各mapper.xml 代码自动生成, 3.配置文件自动生(含:spring,springMVC,mybatis,web.xml); 代码完美运行. 使用: 1.配置generator.xml(key):basepackage...
见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache.xml及web.xml的pageEhCacheFilter 4.MyBatis+Maven代码生成工具。见bin目录 5.作为项目或者技术研究的基础架构。必要的jar包依赖都已配置好,...
6,从前台页面开始向后进行调用,jsp-->sertlet-->service-->daoimpl 。 7,依次实现各层方法。 主要用的三层架构实现: (1)表示层(USL,即User Show Layer):视图层 a. 前台:对应于MVC中的View,用于...
*DAOImpl,DAO实现类 20 在struts.xml中配置页面跳转关系, 21 在applicationContext.xml中配置类之间的调用关系, 22 通知 23 通知文件MyAdvice,schema方法的通知 23 在applicationContext.xml中配置通知--通知文件...
DAOImpl --> DAO接口Implements实现类 程序配置 --> web.xml 验证框架--> bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --> ...
泛型daoimpl :GenericDaoImpl, ID extends Serializable> implements GenericDao, ID> 必须提供的构造方法,以便创建实例的时候就知道具体实体的类型。 daoimpl :PersonDAOImpl extends GenericDaoImpl, ...
泛型daoimpl :GenericDaoImpl, ID extends Serializable> implements GenericDao, ID> 必须提供的构造方法,以便创建实例的时候就知道具体实体的类型。 daoimpl :PersonDAOImpl extends GenericDaoImpl, ...
DAOImpl --> DAO接口Implements实现类 程序配置 --> web.xml 验证框架--> bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验 证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --> ...
DAOImpl --> DAO接口Implements实现类 程序配置 --> web.xml 验证框架--> bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --> ...
DAOImpl --> DAO接口Implements实现类 程序配置 --> web.xml 验证框架--> bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --> log4j...