zoukankan      html  css  js  c++  java
  • SpringDataJPA中NO Session错误

    us 500 - Could not write content: could not initialize proxy - no Session (through reference chain: cn.jiedada.aisell.common.UIPage["rows"]->java.util.UnmodifiableRandomAccessList[0]->cn.jiedada.aisell.domain.Employee["department"]->cn.jiedada.aisell.domain.Department_$$_jvst583_0["id"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: could not initialize proxy - no Session (through reference chain: cn.jiedada.aisell.common.UIPage["rows"]->java.util.UnmodifiableRandomAccessList[0]->cn.jiedada.aisell.domain.Employee["department"]->c

    因为hibernate的底层是通过session来实现CRUD,所以当关闭EntityManager时候所以会出现这个异常

    在web.xml中配置

    <!--解决获取部门懒加载noSession,配置JPA:OpenEntityMangerInViewFilter/Hibernater:OpenSessionMangerInViewFilter-->
        <!--Spring集成JPA必须配置-->
        <filter>
            <filter-name>OpenEntityMangerInViewFilter</filter-name>
            <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>OpenEntityMangerInViewFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    ————————————————
    版权声明:本文为CSDN博主「布谷_」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/qq_42136250/article/details/88581844
    View Code
  • 相关阅读:
    mysql BETWEEN操作符 语法
    mysql IN操作符 语法
    mysql LIKE通配符 语法
    mysql TOP语句 语法
    mysql DELETE语句 语法
    mysql Update语句 语法
    mysql INSERT语句 语法
    mysql ORDER BY语句 语法
    mysql OR运算符 语法
    mysql AND运算符 语法
  • 原文地址:https://www.cnblogs.com/xiaoruirui/p/11669512.html
Copyright © 2011-2022 走看看