Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在spring petclinic中设置hibernate.max_fetch_深度_Java_Spring_Hibernate_Spring Mvc_Jpa - Fatal编程技术网

Java 在spring petclinic中设置hibernate.max_fetch_深度

Java 在spring petclinic中设置hibernate.max_fetch_深度,java,spring,hibernate,spring-mvc,jpa,Java,Spring,Hibernate,Spring Mvc,Jpa,我正在试用SpringPetClinic应用程序,完整的代码是。我想设置hibernate.max\u fetch\u depth=0,但当我重新启动tomcat服务器并从eclipse重新启动应用程序时,我似乎无法使此设置生效 这是我应该将hibernate.max\u fetch\u depth=0设置放在哪个配置文件中,我应该使用什么确切的语法? 我试着把它放在business config.xml中: <property name="jpaProperties">

我正在试用SpringPetClinic应用程序,完整的代码是。我想设置
hibernate.max\u fetch\u depth=0
,但当我重新启动tomcat服务器并从eclipse重新启动应用程序时,我似乎无法使此设置生效

这是我应该将
hibernate.max\u fetch\u 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>  
 hibernate.max_fetch_depth=0  

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

我创建了
hibernate.properties
文件,并将其放在
src/main/resources

将以下条目添加到属性文件并重新启动服务器:

max\u fetch\u depth=3


从日志中,我可以验证该属性是否已在hibernate配置中设置。

我在以下测试中设置了它:

然后我删除了SessionFactory类的bug:

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>   


您是否找到了它为什么不工作的原因?过度继承导致了这个问题。你在回答根本问题时说了这一点。最后,为了减少联接中包含的表的数量,我将部分模式展平。谢谢你的跟进。我还有一个冬眠问题。你也愿意帮我吗?以下是链接:
<properties>
    <property name="hibernate.max_fetch_depth" value="0"/>
</properties>