fetchsize jdbc_hibernate.jdbc.fetch_size的默认大小是多少?

bd96500e110b49cbb3cd949968f18be7.png

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:

3.4. Optional configuration properties

...

hibernate.jdbc.fetch_size: A non-zero value determines the JDBC fetch size (calls

Statement.setFetchSize())

And here is what the javadoc has to say about Statement#setFetchSize():

Gives the JDBC driver a hint as to the

number of rows that should be fetched

from the database when more rows are

needed for ResultSet objects genrated

by this Statement. If the value

specified is zero, then the hint is

ignored. The default value is zero.

In other words, when using a null fetch_size, the JDBC driver will use the default value which is zero.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值