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
  • 相关阅读:
    匈牙利算法自主总结
    luogu P2071 座位安排
    luogu P1613 跑路
    luogu P1250 种树
    luogu P1744 采购特价商品
    网络流
    其他图论
    组合计数
    小技巧
    矩阵&&高斯消元
  • 原文地址:https://www.cnblogs.com/xiaoruirui/p/11669512.html
Copyright © 2011-2022 走看看