[ 
https://issues.apache.org/jira/browse/OLINGO-118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13873120#comment-13873120
 ] 

Michael Bolz commented on OLINGO-118:
-------------------------------------

??I want to be able to avoid running db queries to recreate the schema every 
time an entry or feed is requested.??

IMHO if you want to use the {{ODataSingleProcessor}} (created via 
{{ODataServiceFactory.createODataSingleProcessorService(..)}}) the best way to 
avoid db queries (aka cache the metadata) is to cache the _schema_ within your 
custom {{EdmProvider}} implementation (in the {{getSchema() method}}.
Because within the metadata read in the default {{ODataSingleProcessor}} the 
_schema_ is get from the {{EdmProvider}} and then will be just serialized (for 
deeper look into processing see {{EdmServiceMetadataImplProv.getMetadata()}}):

{code}
  public InputStream getMetadata() throws ODataException {
    if (schemas == null) {
      schemas = edmProvider.getSchemas();
    }

    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    EntityProviderException cachedException = null;
    DataServices metadata = new 
DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion());

    try {
      writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
      XMLStreamWriter xmlStreamWriter = 
XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
      XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null);
      return csb.getInputStream();
}
...
{code}

I hope this answers your question.

Kind regards,
Michael

> Typing of odata entry properties
> --------------------------------
>
>                 Key: OLINGO-118
>                 URL: https://issues.apache.org/jira/browse/OLINGO-118
>             Project: Olingo
>          Issue Type: Question
>    Affects Versions: V2 1.1.0
>            Reporter: M Carissimi
>         Attachments: odata4j output.xml, olingo output.xml
>
>
> Hello,
> I am migrating an odata service from odata4j to olingo. During creation of 
> single odata entries or odata feeds, odata4j allows you to specify the type 
> of each property element. How can this be achieved in olingo? See attached 
> xml feeds for an entry generated in odata4j and one generated in olingo.
> We generate the metadata at runtime using custom database queries and in 
> odata4j we can cache the metadata document to avoid having to rebuild it 
> every time a request is received. How can metadata be cached between requests 
> in olingo? Following the simple read example on the olingo website, we use an 
> ODataServiceFactory to create a service using method 
> createODataSingleProcessorService(), but these methods are invoked during 
> each request.
> Cheers



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to