Search code examples
jpastored-procedureseclipselinkprocedureclob

JPA EclipseLink Call NamedStoredProcedureQuery with Clob parameter (IN and OUT)


Prompt how better to call the procedure with IN-parameters (Clob) and then parse the OUT-parameters. (Clob)

For JDBC I found this case. How I can impliment it with JPA and EclipseLink


Solution

  • Create Clob:

        Clob clobR = null;
        try {
            Connection conn = em.unwrap(Connection.class);
            java.sql.Connection con2 = conn.getMetaData().getConnection();
            clobR = con2.createClob();
            clobR.setString(START_POSITION, data);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    

    Call procedure:

    StoredProcedureQuery query = em.createStoredProcedureQuery(name);
        query.registerStoredProcedureParameter(paramName, type, mode);
        query.setParameter(paramName, value);