RT,,没有配置任何事务,包括包括编程式和声明式的,请我我该手动去关闭session吗?假如要关,又该如何去关.我怕假如应该关,而我又没关,会导致session过多而使程序变慢甚至使服务器崩掉.
解决方案 »
- 帮我分析一下,这个值为什么是空……
- struts里frombean的问题
- 如何在客户端实现批量打印?
- 《精通Hibernate--Java数据库持久层开发核心编程》这本书怎么样
- 如何对一个二维数组排序?在线等,解决马上给分!
- 写一个jsp网站的具体步骤
- 在tomcat中配置连接池都需要做什么
- 怎样准确统计聊天室人数?
- windows 2000 professional+jdk1.4+tomcat安装失败(dos窗体一闪即逝了),如何解决???
- okhtt问题,在idea中运行没问题,打成jar包后报错!!?
- window.location.href 在ie中无效 permission denied
- 求一个ajax分页代码
<!--定义代理方式是什么,在哪个类中进行事务代理,以什么方式进行事务控制 -->
<bean id="baseProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" >
<property name="transactionManager" ref="transactionManager" />
<property name="target">
<ref bean="baseDao"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="modify*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>在service层上实用代理(如在applicationContext_service.xml上):
<bean id="departmentService" class="com.oneal.edusystem.service.impl.DepartmentServiceImpl">
<property name="departmentDao" ref="departmentDao"/>
</bean>
<bean id="departmentProxy" parent="baseProxy">
<property name="target">
<ref bean="departmentService"/>
</property>在action层上就可以用代理方式注入了(如在applicationContext_action.xml上):<bean id="departmentAction" class="com.oneal.edusystem.web.DepartmentAction">
<property name="departmentService" ref="departmentProxy"/>
<property name="excelService" ref="excelService"/>
</bean>
public OperatingLog getOperatingLogById(String id){
try {
long iid = Integer.parseInt(id);
OperatingLog ol = (OperatingLog) getHibernateTemplate().get(OperatingLog.class, iid);
return ol;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
如果需要,我该如何去关session呢?
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
这是一种好的方法,但有一个缺点,就是网络速度很慢的时候,如果页面还没显示完,就被用户关掉了,那这个session就没有关了。