AssortHibernateImpl.java
上传用户:yunfeng252
上传日期:2022-07-23
资源大小:12403k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
Java
- package org.yufeng.dao.hibernate;
- import java.util.List;
- import org.hibernate.Query;
- import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
- import org.yufeng.dao.IAssortDao;
- import org.yufeng.domains.Assort;
- import org.yufeng.utils.AppContext;
- public class AssortHibernateImpl extends HibernateDaoSupport implements
- IAssortDao {
- public List browseAssort(){
- return this.getHibernateTemplate().find("From Assort a order by a.as_id");
- }
- public List browseAssortById(Integer id){
- return this.getHibernateTemplate().find("From Assort a where as_id="+id);
- }
- public List browseAllAssortById(Integer id){
- return this.getHibernateTemplate().find("From Assort a where as_sort_id="+id);
- }
- public Assort loadAssort(Integer id){
- return (Assort) this.getHibernateTemplate().get(Assort.class, id);
- }
- public boolean delAssort(Assort assort){
- boolean flag = false;
- try {
- this.getHibernateTemplate().delete(assort);
- flag = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return flag;
- }
- public boolean delAllAssort(String id){
- boolean flag = false;
- try {
- Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("delete from Assort where as_id=:as_id");
- query.setString("as_id",id);
- query.executeUpdate();
- flag = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return flag;
- }
- public boolean addAssort(Assort assort){
- boolean flag = false;
- try {
- this.getHibernateTemplate().save(assort);
- flag = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return flag;
- }
- public boolean updateSort(String as_name,String edit_name){
- boolean flag = false;
- try {
- Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("update Assort set as_name=:edit_name where as_name=:as_name");
- query.setString("as_name", as_name);
- query.setString("edit_name", edit_name);
- query.executeUpdate();
- flag = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return flag;
- }
- }