我有一个 Sprint Boot 项目,其中包含开放会话。当我尝试对这样的列表进行排序时
<th:block th:each="e : ${#lists.sort(entity.getElements(), new com.example.CustomerComparator())}"
th:include="fragments/table-row::row(elem = ${e})">
</th:block>
我得到一个 LazyInitializationException
我有一个 Sprint Boot 项目,其中包含开放会话。当我尝试对这样的列表进行排序时
<th:block th:each="e : ${#lists.sort(entity.getElements(), new com.example.CustomerComparator())}"
th:include="fragments/table-row::row(elem = ${e})">
</th:block>
我得到一个 LazyInitializationException
原因是百里香叶
解决方法:将列表包装在普通列表中
<th:block th:each="e : ${#lists.sort(new java.util.ArrayList(entity.getElements()), new com.example.CustomerComparator())}"
th:include="fragments/table-row::row(elem = ${e})">
</th:block>