EntityManager em; String functionName = "NameOfStoredFunction"; Map<String, Object> arguments = new LinkedHashMap(); arguments.put("nameOfArgument", "value"); StoredFunctionCall functionCall = new StoredFunctionCall(); functionCall.setProcedureName(functionName); functionCall.setResult("RESULT", String.class); for(String key : arguments.keySet()){ functionCall.addNamedArgumentValue(key, arguments.get(key)); } ValueReadQuery valQuery = new ValueReadQuery(); valQuery.setCall(functionCall); Query query = ((JpaEntityManager)em.getDelegate()).createQuery(valQuery); String call_result = (String)query.getSingleResult();
/** * INTERNAL: */ public void processResult(StoredFunctionCall call, int index) { process(call, index); // Process the function parameter if (hasType()) { if (hasJdbcType() && hasJdbcTypeName()) { OracleArrayTypeMetadata aType = null; if (hasTypeName() && (aType = getArrayTypeMetadata(m_typeName)) != null) { call.setResult(m_jdbcType, m_jdbcTypeName, getJavaClass(m_type), buildNestedField(aType)); } else { call.setResult(m_jdbcType, m_jdbcTypeName, getJavaClass(m_type)); } } else { call.setResult(m_name, getJavaClass(m_type)); } } else if (hasJdbcType() && hasJdbcTypeName()) { call.setResult(m_name, m_jdbcType, m_jdbcTypeName); } else if (hasJdbcType()) { call.setResult(m_name, m_jdbcType); } else { call.setResult(m_name); } }
@Override protected void setSingleResult(XRServiceAdapter xrService, StoredProcedureCall spCall, QName resultType) { if (isCursorType(xrService, resultType)) { spCall.useUnnamedCursorOutputAsResultSet(); } else { StoredFunctionCall sfCall = (StoredFunctionCall)spCall; Class<?> clz = SCHEMA_2_CLASS.get(resultType); if (clz != null) { sfCall.setResult("", clz); } else { sfCall.setResult("", OBJECT); } DatabasePlatform platform = xrService.getORSession().getPlatform(); if (platform == null) { platform = new DatabasePlatform(); } // StoredFunction's return value is the first parameter ((DatabaseField)sfCall.getParameters().get(0)).setSqlType( platform.getJDBCType(clz)); } } }
@Override protected void setSingleResult(XRServiceAdapter xrService, StoredProcedureCall spCall, QName resultType) { if (isCursorType(xrService, resultType)) { spCall.useUnnamedCursorOutputAsResultSet(); } else { StoredFunctionCall sfCall = (StoredFunctionCall)spCall; Class<?> clz = SCHEMA_2_CLASS.get(resultType); if (clz != null) { sfCall.setResult("", clz); } else { sfCall.setResult("", OBJECT); } DatabasePlatform platform = xrService.getORSession().getPlatform(); if (platform == null) { platform = new DatabasePlatform(); } // StoredFunction's return value is the first parameter ((DatabaseField)sfCall.getParameters().get(0)).setSqlType( platform.getJDBCType(clz)); } } }