2017-03-24 14 views
0

この質問には何百万回もの質問がありましたが、私がサイトで見つけた回答はどれも単純な例ではありませんでした。Oracle Hibernate:順序付けバインディングと名前付きバインディングを組み合わせることはできません。

私はパラメータと(単にテストのための)パラメータを持つ単純なストアドプロシージャを持っています、私は最終的な手順のためのカーソルは必要ありません。

Procedure testout (
        a_s_out IN OUT VARCHAR2, 
        -- 
        a_s_in IN VARCHAR2 
       ) 
IS 
BEGIN 
    a_s_out := 'Votre demande de creation ' || a_s_in || ' est réussi.'; 
END testout; 

とJavaコード:

@Service 
public class TablesDaoImpl implements ITablesDao { 
    @Autowired 
    private SessionFactory sessionFactory; 
    final static String PRC_TESTOUT = "PCK_TOOLS.testout"; 

    private static Logger log = Logger.getLogger(TablesDaoImpl.class.getName()); 


    @Override 
    public String createTable(final String newTabId) { 
     ProcedureCall call = sessionFactory.getCurrentSession().createStoredProcedureCall(PRC_TESTOUT); 
     ParameterRegistration<String> p1 = call.registerParameter("a_s_out", String.class, ParameterMode.INOUT); 
     ParameterRegistration<String> p2 = call.registerParameter("a_s_in", String.class, ParameterMode.IN); 
     p1.bindValue(""); 
     p2.bindValue(newTabId); 

     final ProcedureOutputs po = call.getOutputs(); 

     final String str = po.getOutputParameterValue(p1); 

     log.info("Sortie : " + str); 

     return null; 
    } 


} 

しかし、私はこの行final String str = po.getOutputParameterValue(p1);にSQLエラーを得た:

2017-03-24 17:26:59,129 [HJwlMLxG DEV] WARN [SqlExceptionHelper] : SQL Error: 17090, SQLState: 99999 
2017-03-24 17:26:59,129 [HJwlMLxG DEV] ERROR [SqlExceptionHelper] : opération interdite: Ordinal binding and Named binding cannot be combined! 
2017-03-24 17:26:59,130 [HJwlMLxG DEV] ERROR [LoggingHandlerExceptionResolver] : Spring MVC Exception for [GET /api/tables/tables/creerTable] : Unable to extract OUT/INOUT parameter value 
class org.hibernate.exception.GenericJDBCException:Unable to extract OUT/INOUT parameter value 

なぜ?私はよく、私はなぜKWOない...それは同じ失敗だOUTパラメータで

+0

'ProcedureCall'と' ParameterRegistrationであるライブラリから'? GoogleはJavadocを見つけることができないようだ。あなたの輸入品を見せて、どこに図書館があるのか​​教えてください。 –

+0

こんにちは、これは私の輸入です: '輸入javax.persistence.ParameterMode;' ' 輸入org.apache.log4j.layout.Log4j1XmlLayout;' ' 輸入org.hibernate.SessionFactory;' ' インポートorg.hibernate。 procedure.ParameterRegistration; '' 輸入org.hibernate.procedure.ProcedureCall; '' 輸入org.hibernate.procedure.ProcedureOutputs; '' 輸入org.hibernate.result.ResultSetOutput; '' 輸入org.springframework.beans。 factory.annotation.Autowired; ' 'インポートorg.springframework.stereotype.Service; ' hibernate-validator 4.1.0とhibernate-core 5.0.9;春4.2.5 – DarkChyper

答えて

0

を試してみましたが、私はこのように行う場合、それは動作します:

ParameterRegistration<String> p1 = call.registerParameter(0, String.class, ParameterMode.INOUT); 
ParameterRegistration<String> p2 = call.registerParameter(1, String.class, ParameterMode.IN); 

p1.bindValue(""); 
p2.bindValue(newTabId); 

final ProcedureOutputs po = call.getOutputs(); 
final String str = po.getOutputParameterValue(p1); 
log.info("Sortie : " + str); 
関連する問題