gpt4 book ai didi

java - 在 spring petclinic 中设置 hibernate.max_fetch_depth

转载 作者:行者123 更新时间:2023-11-30 03:41:14 29 4
gpt4 key购买 nike

我正在尝试 spring petclinic 应用程序,其完整代码是 at this link 。我想设置 hibernate.max_fetch_depth=0,但是当我重新启动 tomcat 服务器并从 eclipse 重新启动应用程序时,我似乎无法使此设置生效。

这里是a link to the directory that contains all the config files我应该在哪个配置文件中放置 hibernate.max_fetch_depth=0 设置,以及我应该使用什么确切的语法?

我尝试将其放入 business-config.xml 中:

<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.max_fetch_depth">0</prop>
</props>
</property>

我还尝试将其放入data-access.properties:

 hibernate.max_fetch_depth=0  

但这两种方法似乎都不起作用。

最佳答案

我在 GitHub 的一个测试中设置了它:

properties.put("hibernate.max_fetch_depth", "0");

然后我调试了 SessionFactory 类:

Integer maxFetchDepth = ConfigurationHelper.getInteger( AvailableSettings.MAX_FETCH_DEPTH, properties );
if ( maxFetchDepth != null ) {
LOG.debugf( "Maximum outer join fetch depth: %s", maxFetchDepth );
}
settings.setMaximumFetchDepth( maxFetchDepth );

而且效果非常好:

DEBUG [main]: o.h.c.SettingsFactory - Maximum outer join fetch depth: 0

尝试在 persistence.xml 中定义它:

<properties>
<property name="hibernate.max_fetch_depth" value="0"/>
</properties>

关于java - 在 spring petclinic 中设置 hibernate.max_fetch_depth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26790571/

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