2

I have a Java project where I call a stored procedure using hibernate.

Here is sample code I am using

  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; 
    }

This works fine and results the expected results. However It leaves the following message in my logs

[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.

I was looking through websites and the source code of hibernate to try and figure out how to get rid of this warning

Any help is greatly appreciated

Cheers Damien

2 Answers 2

1

It's related to the correction of 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.

So, the warning warn you from calling a method that queries metadata on named parameters.

Sign up to request clarification or add additional context in comments.

Comments

0
    Session session=HibernateUtil.getSessionFactory().openSession();
    Transaction tx=session.beginTransaction();
    
    System.out.println("Enter Id:");
    int id=sc.nextInt();
    
    StoredProcedureQuery query=session.createStoredProcedureCall("Delete",Employee.class);
    query.registerStoredProcedureParameter("id", Integer.class, ParameterMode.IN);
    
    query.setParameter("id",sc.nextInt());
    query.executeUpdate();
    tx.commit();
    

4 Comments

org.hibernate.procedure.internal.ProcedureCallImpl prepareForNamedParameters WARN: HHH000456: Named parameters are used for a callable statement, but database metadata indicates named parameters are not supported. this error shows me
DROP PROCEDURE IF EXISTS namednative_crud.Delete $$ CREATE PROCEDURE namednative_crud.Delete (IN eid int) BEGIN delete from Employee where id=eid; End
this is the query i written and then shows above error
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.