gpt4 book ai didi

java - Hibernate异常: No Hibernate Session bound to thread

转载 作者:行者123 更新时间:2023-12-01 15:48:40 24 4
gpt4 key购买 nike

我收到此异常,经过大量研发后我无法解决它。

基本上,当使用位于 hbnpojogen-persistence-1.4.4.jar

中的 findAll() 方法时,就会出现错误
public abstract interface GenericDAO<T, PK extends Serializable>

public abstract List<T> findAll();

这是尝试使用此方法的代码。

HibernateFactory.getDataDao().findAll();

最佳答案

您需要在执行findAll()之前打开一个事务。参见例如Spring 的 HibernateTransactionManager@Transactional 注释。

关于java - Hibernate异常: No Hibernate Session bound to thread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6575251/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com