本文介绍了hibernate.jdbc.fetch_size的默认大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我们知道默认情况下,大多数jdbc驱动程序的抓取大小是10。 有没有人知道hibernate中的默认抓取大小,即hibernate.jdbc.fetch_size是 $ c> instance。这是通过 ohcSettingsFactory#buildSettings()方法完成的,它包含以下行: code> Integer statementFetchSize = PropertiesHelper.getInteger(Environment.STATEMENT_FETCH_SIZE,properties); if(statementFetchSize!= null)log.info(JDBC result set fetch size:+ statementFetchSize); settings.setJdbcFetchSize(statementFetchSize); 因此,允许使用 null 此设置随后用于 ohjAbstractBatcher.java#setStatementFetchSize code>: private void setStatementFetchSize(PreparedStatement语句)throws SQLException { Integer statementFetchSize = factory.getSettings ().getJdbcFetchSize(); if(statementFetchSize!= null){ statement.setFetchSize(statementFetchSize.intValue()); } } 这个私有方法在准备 PreparedStatement 或 CallableStatement 。请参阅 AbstractBatcher 中的 prepareQueryStatement 和 prepareCallableQueryStatement 。 所以,默认值是 null ,并导致Hibernate不调用语句#setFetchSize code>。 这实际上归纳在参考文档中:换句话说,当使用 null fetch_size ,JDBC驱动程序将使用零的默认值。 We know by default, most of jdbc drivers' fetch sizes are 10.does anyone know what the default fetch size in hibernate, namely hibernate.jdbc.fetch_size is? 解决方案 Basically, all the configuration settings are used to build a o.h.c.Settings instance. This is done by the o.h.c.SettingsFactory#buildSettings() method which contains the following lines:Integer statementFetchSize = PropertiesHelper.getInteger(Environment.STATEMENT_FETCH_SIZE, properties);if (statementFetchSize!=null) log.info("JDBC result set fetch size: " + statementFetchSize);settings.setJdbcFetchSize(statementFetchSize);So, a null value is allowed, it won't be translated and will be "propagated" as such.This setting is then used in o.h.j.AbstractBatcher.java#setStatementFetchSize:private void setStatementFetchSize(PreparedStatement statement) throws SQLException { Integer statementFetchSize = factory.getSettings().getJdbcFetchSize(); if ( statementFetchSize!=null ) { statement.setFetchSize( statementFetchSize.intValue() ); }}This private method is called when preparing a PreparedStatement or a CallableStatement. See prepareQueryStatement and prepareCallableQueryStatement in AbstractBatcher.So, the default value is null and results in Hibernate not calling Statement#setFetchSize().This is actually summarized in the Reference Documentation:And here is what the javadoc has to say about Statement#setFetchSize():In other words, when using a null fetch_size, the JDBC driver will use the default value which is zero. 这篇关于hibernate.jdbc.fetch_size的默认大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-28 07:10