@Override public void setAttributeValueInObject(Object domainObject, Object attributeValue) throws DescriptorException { StoredFunctionCall sfc = (StoredFunctionCall)domainObject; StoredProcedureOutArgument spoa = (StoredProcedureOutArgument)attributeValue; // Set procedure argument name. sfc.getProcedureArgumentNames().set(0, spoa.argumentName); sfc.getParameters().set(0, spoa.getDatabaseField()); // Set argument type. sfc.getParameterTypes().set(0, OUT); } }
@Override protected StoredProcedureCall createCall() { return new StoredFunctionCall(); }
public StoredFunctionCall() { super(); addUnamedOutputArgument(""); }
/** * PUBLIC: * Define to return cursor as result. */ public void setResultCursor() { getParameterTypes().set(0, OUT_CURSOR); setIsCursorOutputProcedure(!hasOutputCursors()); setIsMultipleCursorOutputProcedure(hasOutputCursors()); } }
@Override public Object getAttributeValueFromObject(Object anObject) throws DescriptorException { StoredFunctionCall sfc = (StoredFunctionCall)anObject; Object argument = sfc.getParameters().get(0); String argumentName = (String)sfc.getProcedureArgumentNames().get(0); StoredProcedureOutArgument outArgument = new StoredProcedureOutArgument((DatabaseField)argument); outArgument.argumentName = argumentName; return outArgument; } @Override
/** * PUBLIC: * Define the field name to be substitute for the function return. */ public void setResult(String name) { DatabaseField returnField = (DatabaseField)getParameters().get(0); returnField.setName(name); }
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();
@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)); } } }
public void process(AbstractSession session) { StoredFunctionCall call = new StoredFunctionCall(); call.setProcedureName(getProcedureName());
/** * 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); } }
/** * PUBLIC: * Define the field name to be substitute for the function return. */ public void setResult(String name) { DatabaseField returnField = (DatabaseField)getParameters().firstElement(); returnField.setName(name); }
/** * PUBLIC: * Define to return cursor as result. */ public void setResultCursor() { getParameterTypes().set(0, OUT_CURSOR); setIsCursorOutputProcedure(!hasOutputCursors()); setIsMultipleCursorOutputProcedure(hasOutputCursors()); } }
@Override public Object getAttributeValueFromObject(Object anObject) throws DescriptorException { StoredFunctionCall sfc = (StoredFunctionCall)anObject; Object argument = sfc.getParameters().get(0); String argumentName = sfc.getProcedureArgumentNames().get(0); StoredProcedureOutArgument outArgument = new StoredProcedureOutArgument((DatabaseField)argument); outArgument.argumentName = argumentName; return outArgument; } @Override
@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 public void setAttributeValueInObject(Object domainObject, Object attributeValue) throws DescriptorException { StoredFunctionCall sfc = (StoredFunctionCall)domainObject; StoredProcedureOutArgument spoa = (StoredProcedureOutArgument)attributeValue; // Set procedure argument name. sfc.getProcedureArgumentNames().set(0, spoa.argumentName); sfc.getParameters().set(0, spoa.getDatabaseField()); // Set argument type. sfc.getParameterTypes().set(0, OUT); } }
/** * PUBLIC: * Define the field name to be substitute for the function return. */ public void setResult(String name) { DatabaseField returnField = (DatabaseField)getParameters().get(0); returnField.setName(name); }
@Override public Object getAttributeValueFromObject(Object anObject) throws DescriptorException { StoredFunctionCall sfc = (StoredFunctionCall)anObject; Object argument = sfc.getParameters().get(0); String argumentName = sfc.getProcedureArgumentNames().get(0); StoredProcedureOutArgument outArgument = new StoredProcedureOutArgument((DatabaseField)argument); outArgument.argumentName = argumentName; return outArgument; } @Override
public StoredFunctionCall(int sqlType, String sqlTypeName, Class javaType) { super(); addUnamedOutputArgument("", sqlType, sqlTypeName, javaType); }
@Override protected StoredProcedureCall createCall() { return new StoredFunctionCall(); }
@Override public void setAttributeValueInObject(Object domainObject, Object attributeValue) throws DescriptorException { StoredFunctionCall sfc = (StoredFunctionCall)domainObject; StoredProcedureOutArgument spoa = (StoredProcedureOutArgument)attributeValue; // Set procedure argument name. sfc.getProcedureArgumentNames().set(0, spoa.argumentName); sfc.getParameters().set(0, spoa.getDatabaseField()); // Set argument type. sfc.getParameterTypes().set(0, OUT); } }