hibernate对数据库的简单操作
2015-07-17 15:07
561 查看
import java.io.Serializable; import java.util.List; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.iman.dao.base.BaseDao; public class BaseDaoImpl extends HibernateDaoSupport implements BaseDao{ public boolean save(Object obj) throws Exception{ try { this.getHibernateTemplate().save(obj); return true; } catch (Exception e) { e.printStackTrace(); return false; } } public boolean update(Object obj) throws Exception{ try { this.getHibernateTemplate().update(obj); return true; } catch (Exception e) { e.printStackTrace(); return false; } } public boolean saveOrUpdate(Object obj) throws Exception{ try { this.getHibernateTemplate().saveOrUpdate(obj); return true; } catch (Exception e) { e.printStackTrace(); return false; } } public boolean saveOrUpdateAll(List<?> list) throws Exception{ try { this.getHibernateTemplate().saveOrUpdateAll(list); return true; } catch (Exception e) { e.printStackTrace(); return false; } } public Object get(Class<?> className, Serializable id)throws Exception{ return getHibernateTemplate().get(className, id); } public boolean delete(Object object) throws Exception{ try { this.getHibernateTemplate().delete(object); return true; } catch (Exception e) { e.printStackTrace(); return false; } } public boolean deleteAll(List<?> ls) throws Exception{ try { this.getHibernateTemplate().deleteAll(ls); return true; } catch (Exception e) { e.printStackTrace(); return false; } } }
相关文章推荐
- MySQL5.6的复制从传统方式改为GTID方式
- centos下 redis主从集群以及监控配置
- SQL 索引
- SQL 中的 1NF 2NF 3NF三大范式
- Redis介绍以及安装(Linux)
- redis双机热备(伪Redis Cluster)
- Redigo--Go连接Redis
- MySQL 存储过程和存储引擎
- 使用pymongo需要手动关闭MongoDB Connection吗?
- SQL中 将同一个表中的A列更新到B列,B列更新到A列
- MongoDB分表与分片选择的一次实践
- 数据库连接池配置:C3P0、DBCP、Proxool
- oracle闪回
- MySQL unsigned默认显示字符宽度比signed少一个
- Mysql多表关联删除操作
- Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket
- sql limit的用法
- Oracle 使用小计(4)
- oracle建表带 表注释,字段注释的写法
- Java中使用Oracle的客户端 load data和sqlldr命令执行数据导入到数据库中