gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 02:56:29 24 4
gpt4 key购买 nike

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

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

  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.

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

关于Java - Hibernate 调用 MySql 存储过程 - 警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30202490/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com