先整合red5+hibernate
1.添加jar包 (图中选中),其它一些包red5自带有,如:spring-core.jar等
2.red5应用的web-inf下添加 red5-hibernate.xml.
3.添加以下配置
- <!-- 数据源 //-->
- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
- destroy-method="close">
- <property name="driverClass" value="com.mysql.jdbc.Driver">
- </property>
- <property name="minPoolSize" value="20"></property>
- <property name="initialPoolSize" value="25"></property>
- <property name="maxPoolSize" value="100"></property>
- <property name="acquireIncrement" value="3"></property>
- <property name="acquireRetryAttempts" value="10"></property>
- <property name="autoCommitOnClose" value="false"></property>
- <property name="acquireRetryDelay" value="2000"></property>
- <property name="jdbcUrl"
- value="jdbc:mysql://192.168.0.74:3306/amusementdb?characterEncoding=utf8">
- </property>
- <property name="user" value="root"></property>
- <property name="password" value=""></property>
- </bean>
- <!-- hibernate会话工厂 -->
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="dataSource">
- <ref bean="dataSource" />
- </property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">
- org.hibernate.dialect.MySQLDialect
- </prop>
- <!-- 10天 -->
- <prop key="hibernate.c3p0.timeout">864000</prop>
- <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory
- </prop>
- </props>
- </property>
- </bean>
添加srping 申明式事务控制(aop)
1.添加上图中没有选中包
2.添加以下配置
- <bean id="transactionManager"
- class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory">
- <ref bean="sessionFactory" />
- </property>
- </bean>
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="get*" propagation="REQUIRED" />
- <tx:method name="add*" propagation="REQUIRED" />
- <tx:method name="delete*" propagation="REQUIRED" />
- </tx:attributes>
- </tx:advice>
- <aop:config>
- <aop:pointcut id="usersServiceMethods" expression="execution(public * com.test.*.*(..))" />
- <aop:advisor advice-ref="txAdvice" pointcut-ref="usersServiceMethods" />
- </aop:config>
xml命名空间申明
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- 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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
hibernateDAO编写
.............自己发挥
完成