Spring持久层(三) Hibernate
来源:互联网 发布:淘宝没有卖家中心 编辑:程序博客网 时间:2024/05/01 06:55
1 先定义配置文件hibernate-context.xml
2 HibernateProductDao.java源代码
3 Product.hbm.xml
4 测试代码实验了保存实体的例子
5 如果不配置事务,则会抛出异常:
Exception in thread "main" org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
at springapp.repository.HibernateProductDao.saveProduct(HibernateProductDao.java:24)
at springapp.repository.HibernateProductDaoTest.main(HibernateProductDaoTest.java:19)
6 使用HibrenateTemplate
HibrenateTemplateDao.java
7 配置文件
8 测试代码
- Spring持久层(三) Hibernate
- spring + hibernate 数据话持久层
- Spring+Hibernate DAO 持久层开发
- Spring+Hibernate DAO 持久层开发, Spring 用 Hibernate 访问数据库的三种方法.推荐使用回调
- Spring+Hibernate DAO 持久层开发, Spring 用 Hibernate 访问数据库的三种方法.推荐使用回调
- Hibernate持久层操作
- Hibernate 持久层操作
- 持久层理解 hibernate
- 使用Hibernate和Spring开发事务性持久层
- spring + hibernate 数据话持久层(转)
- 用 Hibernate 和 Spring 开发事务持久层
- 用 Hibernate 和 Spring 开发事务持久层
- 用 Hibernate 和 Spring 开发事务持久层
- 使用Hibernate 和 Spring 实现一个事务持久层
- 使用Hibernate 和 Spring 实现一个事务持久层
- 用 Hibernate 和 Spring 开发事务持久层
- 使用Spring 管理Hibernate持久层有如下优势
- hibernate做持久层,spring管理事物的架构方式
- Debug VB COM component in IIS7
- java 日期控件,jbutton触发
- How to switch to another database in oracle 11g(如何在oracle中从一个数据库切换到另一个数据库)
- Java 网络编程 学习笔记一 基础知识
- c# 智能设备应用程序不显示在任务栏以及最小化窗体
- Spring持久层(三) Hibernate
- SQL Server 双机热备(based on log shipping)
- poj3463——Sightseeing
- [zz]ubuntu下配置framebuffer
- Java 网络编程 学习笔记二 Socket 用法
- libnids-1.21 中 IP 分片重组分析 之数据结构与处理流程
- SQL Server 负载均衡方案集锦
- JINI和java space入门
- Linux 创建文件系统及挂载文件系统流程详解