HHH000387 Hibernate警告意味着什么?

时间:2021-07-05 11:51:32

I have just updated to Hibernate 4.0 and am seeing the warning message :

我刚刚更新到Hibernate 4.0并看到了警告消息:

HHH000387: ResultSet's statement was not registered

HHH000387:ResultSet的语句未注册

in my log files. What does this mean, and should I be worried?

在我的日志文件中。这是什么意思,我应该担心吗?

5 个解决方案

#1


1  

I would not worry too much. In any case it looks like it is not in API's users hands to avoid this message. Logging is done in the org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl. According documentation:

我不会太担心。在任何情况下,看起来它都不在API的用户手中以避免此消息。记录在org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl中完成。根据文件:

The main function of a JdbcResourceRegistry is to make sure resources get cleaned up.

JdbcResourceRegistry的主要功能是确保清理资源。

Short look to the code tells, that such a message is logged in two situations:

对代码的简要介绍告诉我,在两种情况下记录这样的消息:

  1. ResultSet is registered via register-method, and statement is not registered.
  2. ResultSet通过register-method注册,语句未注册。
  3. ResultSet is released via release-method and statement is not registered.
  4. ResultSet通过release-method释放,语句未注册。

#2


1  

Looking at the source for the JdbcResourceRegistryImpl class that throws this error, I personally think having it log at WARN level is excessive; it should be INFO at most, unless there's a way to have all Statements implicitly registered as part of a Hibernate/framework configuration.

查看抛出此错误的JdbcResourceRegistryImpl类的源代码,我个人认为将其登录到WARN级别是过分的;它应该最多为INFO,除非有办法将所有语句隐式注册为Hibernate /框架配置的一部分。

It's not clear to me why a Statement should be registered, but if it's only a concern of the inner workings of Hibernate then routinely warning API users about it is a bug, right?

我不清楚为什么要注册一个Statement,但如果它只是Hibernate内部工作的一个问题,那么经常警告API用户它是一个bug,对吧?

#3


1  

This log message is a sign that ResultSet.getStatement() doesn't return the Statement which was originally asked to create the ResultSet. (It may also indicate a memory leak.) This can happen when using a JDBC wrapper, because there are two Statement objects: a wrapper/decorator and the underlying Statement.

此日志消息表明ResultSet.getStatement()不返回最初被要求创建ResultSet的Statement。 (它也可能表示内存泄漏。)使用JDBC包装器时会发生这种情况,因为有两个Statement对象:包装器/装饰器和基础语句。

In my project, I have my own JDBC wrapper for testing. I fixed this warning in my ResultSet wrapper by ensuring that getStatement() returns the original Statement proxy (not a new proxy), rather than delegating to the underlying ResultSet (which would return the underlying Statement).

在我的项目中,我有自己的JDBC包装器进行测试。我通过确保getStatement()返回原始的Statement代理(不是新的代理)而不是委托给底层的ResultSet(它将返回基础Statement),在ResultSet包装器中修复了这个警告。

Any JDBC wrapper which is producing similar warnings could probably use a similar fix. (A similar problem and fix may apply to the method Statement.getConnection().)

任何产生类似警告的JDBC包装器都可能使用类似的修复程序。 (类似的问题和修复可能适用于Statement.getConnection()方法。)

By the way, there is a bug report for this logging here: https://hibernate.atlassian.net/browse/HHH-8210

顺便说一下,这里有一个关于此日志记录的错误报告:https://hibernate.atlassian.net/browse/HHH-8210

#4


0  

Did you configured connection pool? I've got the same warning. But if I added c3p0 in my maven dependency and get it correctly configured in hibernate.cfg.xml. The warning disappears.

你配置了连接池了吗?我有同样的警告。但是如果我在maven依赖项中添加c3p0并在hibernate.cfg.xml中正确配置它。警告消失了。

#5


0  

In my case this warning was an indicator of huge performance leak! I have hibernate POJO objects with @oneToOne mapping. For one table it works fine and no warnings: it sends one request to MySQl server for getting all the records and then for one requests for each joined table. For POJO where I'm getting this error (when no @oneToOne found): it sends one initial request for getting a list of all objects and then every time send new and new requests for mapped tables for each record.

在我的情况下,这个警告是一个巨大的性能泄漏的指标!我使用@oneToOne映射来休眠POJO对象。对于一个表,它工作正常,没有警告:它向MySQl服务器发送一个请求以获取所有记录,然后为每个连接表发送一个请求。对于我收到此错误的POJO(当没有找到@oneToOne时):它发送一个初始请求以获取所有对象的列表,然后每次为每个记录发送映射表的新请求和新请求。

So, let's say I have 2000 records in my test DB. And 3 @oneToOne mapped tables.

所以,假设我的测试数据库中有2000条记录。 3个@oneToOne映射表。

In a good case, it sends 1 request for getting a list and 3 requests for getting mapped tables.

在一个好的情况下,它发送1个获取列表的请求和3个获取映射表的请求。

In the case of a warning, it sends 1 initial request for getting list. Then send 3 requests for getting mapped info for each of 2000 records in DB! So 1999*3=5997 additional requests for each user for each call the @Controller (Spring MVC).

如果出现警告,它会发送1个获取列表的初始请求。然后发送3个请求获取数据库中每条2000条记录的映射信息!因此,对于每个调用@Controller(Spring MVC)的每个用户,1999 * 3 = 5997个额外请求。

I hadn't noticed it while the web application and MySQL server were on the same server.

当Web应用程序和MySQL服务器在同一台服务器上时,我没有注意到它。

#1


1  

I would not worry too much. In any case it looks like it is not in API's users hands to avoid this message. Logging is done in the org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl. According documentation:

我不会太担心。在任何情况下,看起来它都不在API的用户手中以避免此消息。记录在org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl中完成。根据文件:

The main function of a JdbcResourceRegistry is to make sure resources get cleaned up.

JdbcResourceRegistry的主要功能是确保清理资源。

Short look to the code tells, that such a message is logged in two situations:

对代码的简要介绍告诉我,在两种情况下记录这样的消息:

  1. ResultSet is registered via register-method, and statement is not registered.
  2. ResultSet通过register-method注册,语句未注册。
  3. ResultSet is released via release-method and statement is not registered.
  4. ResultSet通过release-method释放,语句未注册。

#2


1  

Looking at the source for the JdbcResourceRegistryImpl class that throws this error, I personally think having it log at WARN level is excessive; it should be INFO at most, unless there's a way to have all Statements implicitly registered as part of a Hibernate/framework configuration.

查看抛出此错误的JdbcResourceRegistryImpl类的源代码,我个人认为将其登录到WARN级别是过分的;它应该最多为INFO,除非有办法将所有语句隐式注册为Hibernate /框架配置的一部分。

It's not clear to me why a Statement should be registered, but if it's only a concern of the inner workings of Hibernate then routinely warning API users about it is a bug, right?

我不清楚为什么要注册一个Statement,但如果它只是Hibernate内部工作的一个问题,那么经常警告API用户它是一个bug,对吧?

#3


1  

This log message is a sign that ResultSet.getStatement() doesn't return the Statement which was originally asked to create the ResultSet. (It may also indicate a memory leak.) This can happen when using a JDBC wrapper, because there are two Statement objects: a wrapper/decorator and the underlying Statement.

此日志消息表明ResultSet.getStatement()不返回最初被要求创建ResultSet的Statement。 (它也可能表示内存泄漏。)使用JDBC包装器时会发生这种情况,因为有两个Statement对象:包装器/装饰器和基础语句。

In my project, I have my own JDBC wrapper for testing. I fixed this warning in my ResultSet wrapper by ensuring that getStatement() returns the original Statement proxy (not a new proxy), rather than delegating to the underlying ResultSet (which would return the underlying Statement).

在我的项目中,我有自己的JDBC包装器进行测试。我通过确保getStatement()返回原始的Statement代理(不是新的代理)而不是委托给底层的ResultSet(它将返回基础Statement),在ResultSet包装器中修复了这个警告。

Any JDBC wrapper which is producing similar warnings could probably use a similar fix. (A similar problem and fix may apply to the method Statement.getConnection().)

任何产生类似警告的JDBC包装器都可能使用类似的修复程序。 (类似的问题和修复可能适用于Statement.getConnection()方法。)

By the way, there is a bug report for this logging here: https://hibernate.atlassian.net/browse/HHH-8210

顺便说一下,这里有一个关于此日志记录的错误报告:https://hibernate.atlassian.net/browse/HHH-8210

#4


0  

Did you configured connection pool? I've got the same warning. But if I added c3p0 in my maven dependency and get it correctly configured in hibernate.cfg.xml. The warning disappears.

你配置了连接池了吗?我有同样的警告。但是如果我在maven依赖项中添加c3p0并在hibernate.cfg.xml中正确配置它。警告消失了。

#5


0  

In my case this warning was an indicator of huge performance leak! I have hibernate POJO objects with @oneToOne mapping. For one table it works fine and no warnings: it sends one request to MySQl server for getting all the records and then for one requests for each joined table. For POJO where I'm getting this error (when no @oneToOne found): it sends one initial request for getting a list of all objects and then every time send new and new requests for mapped tables for each record.

在我的情况下,这个警告是一个巨大的性能泄漏的指标!我使用@oneToOne映射来休眠POJO对象。对于一个表,它工作正常,没有警告:它向MySQl服务器发送一个请求以获取所有记录,然后为每个连接表发送一个请求。对于我收到此错误的POJO(当没有找到@oneToOne时):它发送一个初始请求以获取所有对象的列表,然后每次为每个记录发送映射表的新请求和新请求。

So, let's say I have 2000 records in my test DB. And 3 @oneToOne mapped tables.

所以,假设我的测试数据库中有2000条记录。 3个@oneToOne映射表。

In a good case, it sends 1 request for getting a list and 3 requests for getting mapped tables.

在一个好的情况下,它发送1个获取列表的请求和3个获取映射表的请求。

In the case of a warning, it sends 1 initial request for getting list. Then send 3 requests for getting mapped info for each of 2000 records in DB! So 1999*3=5997 additional requests for each user for each call the @Controller (Spring MVC).

如果出现警告,它会发送1个获取列表的初始请求。然后发送3个请求获取数据库中每条2000条记录的映射信息!因此,对于每个调用@Controller(Spring MVC)的每个用户,1999 * 3 = 5997个额外请求。

I hadn't noticed it while the web application and MySQL server were on the same server.

当Web应用程序和MySQL服务器在同一台服务器上时,我没有注意到它。