- 浏览: 245595 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (179)
- Spring3.0 (28)
- HIbernate3.5.6 (35)
- Struts2.1.8 (42)
- JSP (1)
- Servlet (0)
- JAVASE (16)
- JavaWeb (1)
- javaEE (0)
- SSH2整合 (0)
- EJB (0)
- Oracle (7)
- Ajax (7)
- Quartz作业调度框架 (6)
- jsValidationFramework (1)
- FCKeditor (1)
- ExtJS (29)
- JSF (0)
- JPA (0)
- JBoss Seam (0)
- JSON (0)
- Webservice (0)
- JQuery (1)
- Javascript (1)
- Css+DIV (0)
- Lunch (0)
- Linux (0)
- PHP (0)
- XML (1)
- Ibatis (0)
- DWR (0)
- DWZ (0)
最新评论
-
Nabulio:
good
Spring配置SessionFactory -
唤流年:
[color=red][/color] ...
Spring配置SessionFactory -
wangcl011:
Oracle通过数据泵网络导入另一个数据库,不生成DMP文件, ...
oracle命令导入dmp文件 -
rochou:
第一个Hibernate实现CRUD -
ningwuyu:
Entity 类是那个jar里面的
PropertyUtils MethodUtils用法
package com.zchen.dao.impl;
import javax.annotation.Resource;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;
import com.zchen.dao.UserDAO;
import com.zchen.model.User;
@Component("userDao")
public class UserDAOImpl implements UserDAO {
private HibernateTemplate hibernateTemplate;
public HibernateTemplate getHibernateTemplate() {
return hibernateTemplate;
}
@Resource
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public void save(User user) {
hibernateTemplate.save(user);
}
}
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <context:annotation-config /> <context:component-scan base-package="com.zchen" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/spring" /> <property name="username" value="root" /> <property name="password" value="bjsxt" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>com.zchen.model.User</value> <value>com.zchen.model.Log</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <aop:config> <aop:pointcut id="bussinessService" expression="execution(public * com.zchen.service..*.*(..))" /> <aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="getUser" read-only="true" /> <tx:method name="add*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> </beans>
发表评论
-
总结spring下配置dbcp,c3p0,proxool数据源链接池
2011-06-03 23:04 1338applicationContext-datasource-j ... -
Spring简单属性注入
2011-06-03 19:51 934package com.zchen.property; ... -
Spring配置文件定义类时用id和name的区别
2011-06-03 19:43 1059<?xml version="1.0" ... -
Spring_Hibernate_HibernateDaoSupport
2010-11-29 14:49 2925继承HibernateDaoSupport有三种方式: 1. ... -
Spring配置SessionFactory
2010-11-29 14:09 296051.不用dataSource引入hibernate.cfg.x ... -
Spring配置事务管理_XML
2010-11-29 13:46 1255<aop:aspectj-autoproxy proxy ... -
Spring配置事务管理_Annotation
2010-11-29 13:41 1061<?xml version="1.0" ... -
Spring配置DataSource
2010-11-29 13:38 15271.直接引入: <bean id="data ... -
XML配置AOP
2010-11-29 13:22 673package com.zchen.aop; impor ... -
Anotation配置AOP
2010-11-29 13:16 950package com.zchen.aop; impor ... -
Spring面向切向(AOP)编程
2010-11-29 13:08 1058引入:aop scheme。 <?xml versio ... -
@PostConstruct和@PreDestroy注解使用
2010-11-29 13:02 2525package com.zchen.service; imp ... -
@Scope注解使用
2010-11-29 12:59 3882Annotation中的@Scope注解和xml中的Scope ... -
@Component @Service @Controller @Repository注解使用
2010-11-29 12:46 1420@Component 相当于实例化类的对象。 通过在c ... -
@Resource注解使用
2010-11-29 12:31 1639a) 加入:j2ee/common-annotations. ... -
@Autowired注解使用
2010-11-29 12:25 1634a) 默认按类型by type b) 如果想用byName, ... -
Spring的Annotation配置
2010-11-29 12:17 758使用注解先将schema加入到配置文件中: <? ... -
bean的生命周期
2010-11-29 12:13 912public class UserService { ... -
Spring的自动装载模式
2010-11-29 12:08 978在Spring的.xml配置文件中,bean有五种autowi ... -
Spring的作用域
2010-11-29 11:48 13561.Singleton作用域: 当一个bean的作用域为sin ...
相关推荐
Spring_2000_Spring_Hibernate_HibernateTemplate,Spring_2000_Spring_Hibernate_HibernateTemplate
Spring和Hibernate源码下载 Spring_Spring_Hibernate_HibernateTemplate
* 继承HibernateDaoSupport类,使用HibernateTemplate来持久化,HibernateTemplate是 Hibernate Session的轻量级封装 * 默认情况下运行期异常才会回滚(包括继承了RuntimeException子类),普通异常是不会滚的 ...
Spring整合hibernate(2)之基于HibernateTemplate的整合,jar需要自己添加!
Spring+hibernate整合源代码 结束Sping+hibernate 的使用方法 包括演示示例
Spring提供了org.springframework.orm.hibernate3.HibernateTemplate类和org.springframework.orm.hibernate3.HibernateCallback接口来方便和Hibernate整合。 HibernateTemplate类封装了Hibernate的主要类,它提供了...
spring和hibernate整合示例,以一张表的业务操作,来简要说明hibernate和spring的整合,说明spring对HibernateTemplate和调用
Spring控制Hibernate中的事务传播特性与隔离级别操作,通过利用spring和Hibernate的两个HibernateTemplate 和 jdbcTemplate类,实现数据的交互。
6.5 Spring整合Hibernate 6.6 Spring提供的DAO支持 6.5.2 管理Hibernate的SessionFactory 6.5.3 使用HibernateTemplate 6.5.4 使用HibernateCallBack 6.5.6 使用IoC容器组装各种组件 6.5.7启动web容器读取xml配置...
Spring+Hibernate实现增删改查的两种方法,HibernateTemplate实现和HibernateDaoSupport实现
TfileDAOHibernate通过扩展Spring提供的Hibernate支持类HibernateDaoSupport而建立,HibernateDaoSupport封装了HibernateTemplate,而HibernateTemplate封装了Hibernate所提供几乎所有的的数据操作方法,如execute...
本类封装了Spring提供的HibernateTemplate,从提供了对数据的各种操作,因此,本类尤其适合用Spring + Hibernate整合后进行系统开 发时使用。 AnyFoAction功能概述 AnyFoDao中的那个类,提供多个方法来对...
本文主要讲解如何在Spring4.0.4下整合Hibernate4.3.6; 主要介绍了如下内容: 项目结构的规划; Spring MVC的配置和使用; Spring下整合Hibernate的具体过程; 数据源的配置; jdbcTemplate和HibernateTemplate两种...
Spring2.5和Hibernate3集成 采用声明式事务 1.声明式事务的配置 * 配置sessionFactory * 配置事务管理器 * 配置事务的传播特性 * 配置哪些类哪些方法使用事务 2.编写业务逻辑方法 * 继承...
Spring 整合 Hibernate 时启用二级缓存实例详解 写在前面: 1. 本例使用 Hibernate3 + Spring3; 2. 本例的查询使用了 HibernateTemplate; 1. 导入 ehcache-x.x.x.jar 包; 2. 在 applicationContext.xml ...
spring2.5.6与hibernate3.3整合示例,导入即可运行。运用注解、hibernateTemplate、声明式事务管理。包括所有需要jar包。
项目只是个简单的框架集成原型,集成了最新的struts2.3.24,spring4,hibernate4.3.10,使用junit测试通过,很简单的一个环境,对一张表增删改查,使用了hibernateTemplate4操作数据库,有不足之处请指正,谢谢!
1、struts1.2+spring 2.0+hibernate3.2 2、struts的动作交由spring来管理,hibernate的配置集中在spring中配置。 3、增加了声明式事务处理,加强了hibernateTemplate的简单事务处理。 4、完整的Myeclipse的工程文件...
本篇文章主要介绍了Spring4整合Hibernate5详细步骤,具有一定的参考价值,有兴趣的同学可以了解一下