I am experimenting with the spring petclinic app, the complete code for which is at this link. I would like to set hibernate.max_fetch_depth=0
, but I cannot seem to get this setting to take effect when I re-start tomcat server and re-launch the app from eclipse.
Here is a link to the directory that contains all the config files. In which config file should I place the hibernate.max_fetch_depth=0
setting, and what exact syntax should I use?
I tried placing this in 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>
I also tried putting this in data-access.properties
:
hibernate.max_fetch_depth=0
But neither approach seems to work.
I set it in one of my tests in GitHub:
properties.put("hibernate.max_fetch_depth", "0");
Then I debbuged the SessionFactory class:
Integer maxFetchDepth = ConfigurationHelper.getInteger( AvailableSettings.MAX_FETCH_DEPTH, properties );
if ( maxFetchDepth != null ) {
LOG.debugf( "Maximum outer join fetch depth: %s", maxFetchDepth );
}
settings.setMaximumFetchDepth( maxFetchDepth );
And it worked perfectly:
DEBUG [main]: o.h.c.SettingsFactory - Maximum outer join fetch depth: 0
Try defining it in persistence.xml:
<properties>
<property name="hibernate.max_fetch_depth" value="0"/>
</properties>