JPA EclipseLink使用Clob参数调用NamedStoredProcedureQuery(IN和OUT)

时间:2015-11-30 17:58:01

标签: jpa stored-procedures eclipselink procedure clob

提示如何使用IN参数(Clob)调用过程,然后解析OUT参数。 (CLOB)

对于JDBC,我找到了this case。我如何用JPA和EclipseLink来实现它

1 个答案:

答案 0 :(得分:0)

创建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();
    }

通话程序:

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