on-session问题

Posted javajava

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了on-session问题相关的知识,希望对你有一定的参考价值。

.D:\\0kecheng\\bos\\bosv2.0_chapter03.无条件查询.

方法1.@JSON(serialize=false)是注解排除不需要加载的实体类上,找到它的get方法,解决no-session问题.

方法2.只要在web.xml配置:不需要配置上面的@JSON了.(注意死循环问题)  A类用到B,设置set(null),设为空后就断掉循环了.

在hibernate使用Struts2的过滤器前面添加

<filter>
<filter-name>OpenSession</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSession</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

在Spring data jpa使用

<filter>
<filter-name>OpenEntity</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenEntity</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

 方法三:@Lazy(false)(效率较低,不建议使用)

 hibernate默认延迟加载  @Lazy(true).

如果需要将集合数据转换成json有三种方法:

第一种:在业务层手动查询数据 被加载

第二种:配置立即抓取

第三种:OpenEntityManagerInView配置文件.

 

以上是关于on-session问题的主要内容,如果未能解决你的问题,请参考以下文章

如何解决iframe session 失效问题

php的session出错问题

php session跨页面取不到值的问题,高手指教。

关于PHP session会话时间 短的问题

asp中session的问题

redis02_session存在哪,redis解决session的存储问题_session的过期时间默认是半个小时