Java - Hibernate 调用 MySql 存储过程 - 警告消息

Java - Hibernate calling a MySql Stored Procedure - Warning Message

我有一个 Java 项目,我在其中使用休眠调用存储过程。

这是我正在使用的示例代码

  public String findCloudName(Long cloudId) {
        LOG.info("Entered findCloudName Method - cloudId:{}", cloudId);

        String cloudName  = null;
        ProcedureCall  procedureCall = currentSession().createStoredProcedureCall("p_getCloudDetails");
        procedureCall.registerParameter( "cloudId", Long.class, ParameterMode.IN ).bindValue( cloudId );
        procedureCall.registerParameter( "cloudName", String.class, ParameterMode.OUT );

        ProcedureOutputs  outputs = procedureCall.getOutputs();

        cloudName = (String) outputs.getOutputParameterValue( "cloudName" );

        LOG.info("Exiting findCloudName Method - cloudName:{}", cloudName);
        return cloudName; 
    }

这工作正常并产生了预期的结果。 但是它在我的日志中留下了以下消息

[WARN] [320]org.hibernate.procedure.internal.ProcedureCallImpl[prepareForNamedParameters]  - HHH000456: Named parameters are used for a callable statement, but database metadata indicates named parameters are not supported.

我正在浏览网站和 hibernate 的源代码,试图弄清楚如何摆脱这个警告

非常感谢任何帮助

干杯 达米安

HHH-8740的更正有关:

In some cases, the database metadata is incorrect (i.e., says something is not supported, when it actually is supported). In this case it would be preferable to simply log a warning. If it turns out that named parameters really are not supported, then a SQLException will be thrown later when the named parameter is bound to the SQL statement.

因此,警告警告您不要调用查询命名参数元数据的方法。