2016-08-19 6 views
2

mybatisのSpringアプリケーションでは、Oracleのストアド・プロシージャをコールするために必要なSTRUCTSのARRAYのデータを埋めるTypeHandlerがあります。 BLOBエントリは、ストアドプロシージャで適切に埋められ、表示されます。文字列エントリはありません。文字列データは送信されません。エラーや警告はログに記録されません。データはnullではなく、アプリケーションで有効です。データはアプリケーションとOracleの間で単純に消えます。Ibatis TypeHandlerストアド・プロシージャの型のVarcharパラメータ

public void setParameter(PreparedStatement ps, int i, List<MailAttachment> parameter, 
    JdbcType jdbcType) throws SQLException 
{ 
    List<MailAttachment> attachmentList = parameter; 

    OracleConnection oracleConnection = ps.getConnection().unwrap(OracleConnection.class); 

    StructDescriptor structDescriptor = StructDescriptor.createDescriptor(ATTACHMENT, oracleConnection); 
    Object[] structs = null; 
    structs = new Object[attachmentList == null ? 0 :attachmentList.size()]; 
    if (attachmentList != null) { 
     //CharacterSet chs = CharacterSet.make(CharacterSet.UTF8_CHARSET); 
     for (int index = 0; index < attachmentList.size(); index++) { 

      MailAttachment mailAttachment = attachmentList.get(index); 
      BLOB blob = null; 
      if (mailAttachment.getData() != null){ 
       blob = BLOB.createTemporary(oracleConnection,false,BLOB.DURATION_SESSION); 
       // filling blob works 
      } 
      CHAR attachName = new CHAR(mailAttachment.getFilename(), CharacterSet.make(CharacterSet.UTF8_CHARSET)); 
      CHAR contentType = new CHAR(mailAttachment.getContentType(), CharacterSet.make(CharacterSet.UTF8_CHARSET)); 

      STRUCT struct = new STRUCT(structDescriptor, oracleConnection, 
           new Object[] {blob, attachName, contentType, null} 
           ); 
      structs[index] = struct; 
     } 
    } 

    ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor(ATTACHMENT_LIST, oracleConnection); 
    ARRAY oracleArray = new ARRAY(arrayDesc, oracleConnection, structs); 
    ps.setObject(i, oracleArray); 
} 

答えて

1

この問題は、Oracle JDBCドライバと接続され、それは国際化のためのサポートです:

私のハンドラのsetParameter実装では、このようになります。

orai18n.jarは、classpath/pomファイルにojdbc jarファイルの正しいバージョンで含めてください。

のorai18n.jarが欠落している場合:

  • setParametersを使用:Oracle型のVARCHAR2パラメータは
  • のgetResult/getNonNullParameterをnullに設定されます。VARCHAR2パラメータは "???" としてJavaクラスにロードされますが文字列。
関連する問題