olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r914547 - in /websites/staging/olingo/trunk/content: ./ doc/tutorials/HandlingClobAndBlob.html
Date Tue, 01 Jul 2014 07:51:10 GMT
Author: buildbot
Date: Tue Jul  1 07:51:10 2014
New Revision: 914547

Log:
Staging update by buildbot for olingo

Added:
    websites/staging/olingo/trunk/content/doc/tutorials/HandlingClobAndBlob.html
Modified:
    websites/staging/olingo/trunk/content/   (props changed)

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Jul  1 07:51:10 2014
@@ -1 +1 @@
-1606993
+1606999

Added: websites/staging/olingo/trunk/content/doc/tutorials/HandlingClobAndBlob.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/tutorials/HandlingClobAndBlob.html (added)
+++ websites/staging/olingo/trunk/content/doc/tutorials/HandlingClobAndBlob.html Tue Jul 
1 07:51:10 2014
@@ -0,0 +1,185 @@
+<!DOCTYPE html>
+<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
+<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
+<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
+<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
+    <head>
+        <meta charset="utf-8">
+        <meta http-equiv="expires" content="0">
+            <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
+                <title></title>
+                <meta name="description" content="Apache Olingo provides libraries which
enable developers to implement OData producers and OData consumers. The available OData Java
library implements OData version 2.0. In future on goal is to provide an OData 4.0 compliant
library once the OData standard is published at OASIS. The focus within the community is currently
on the Java technology but it is up to the community to discuss if other environments find
interest.">
+                    <meta name="viewport" content="width=device-width">
+                        
+                    <link rel="stylesheet" href="/css/bootstrap.min.css">
+                            <style>
+                                body {
+                                    padding-top: 60px;
+                                    padding-bottom: 40px;
+                                }
+                                </style>
+                                <link rel="stylesheet" href="/css/bootstrap-responsive.min.css">
+                                <link rel="stylesheet" href="/css/main.css">
+                                    
+                                <script src="/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
+                                    </head>
+    <body>
+        <!--[if lt IE 7]>
+         <p class="chromeframe">You are using an <strong>outdated</strong>
browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or
<a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a>
to improve your experience.</p>
+         <![endif]-->
+        
+        <!-- This code is taken from http://twitter.github.com/bootstrap/examples/hero.html
-->
+        <div class="navbar navbar-inverse  navbar-fixed-top">
+            <div class="navbar-inner">
+                <div class="container">
+                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                    </a>
+                    <img class="brand" src="/img/OlingoOrangeTM.png" style="width:42px;"
/>
+                    <a class="brand" href="/">Apache Olingo&trade;</a>
+                   <div class="nav-collapse collapse">
+                        <ul class="nav">
+                            <li class="dropdown">
+                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF
<b class="caret"></b></a>
+                                <ul class="dropdown-menu">
+                                    <li><a href="http://www.apache.org/foundation/">ASF
Home</a></li>
+                                    <li><a href="http://projects.apache.org/">Projects</a></li>
+                                    <li><a href="http://people.apache.org/">People</a></li>
+                                    <li><a href="http://www.apache.org/foundation/getinvolved.html">Get
Involved</a></li>
+                                    <li><a href="http://www.apache.org/dyn/closer.cgi">Download</a></li>
+                                    <li><a href="http://www.apache.org/security/">Security</a></li>
+                                    <li><a href="http://www.apache.org/foundation/sponsorship.html">Support
Apache</a></li>
+                                </ul>
+                            </li>
+                            <li><a href="/">Home</a></li>
+                            <li><a href="http://www.apache.org/licenses/">License</a></li>

+                            <li><a href="/download.html">Download</a></li>
+                            <li><a href="/documentation.html">Documentation</a></li>
+                            <li><a href="/support.html">Support</a></li>
+                        </ul>
+                        <form class="navbar-form pull-right" name="search" id="search"
action="http://www.google.com/search" method="get">
+                            <input value="olingo.apache.org" name="sitesearch" type="hidden"/>
+                            <input class="span2" type="text" name="q" id="query">
+                                <input class="btn"type="submit" id="submit" value="Search">
+                                    </form>
+                    </div><!--/.nav-collapse -->
+                </div>
+            </div>
+        </div>
+        
+        <div class="container">
+            
+            
+            
+            <h2 id="handling-blob-and-clob-data-types">Handling BLOB and CLOB Data
Types</h2>
+<p>JPA entities can have properties that are of type java.sql.Blob or java.sql.Clob.
Internally, JPA entities can instantiate a JPA provider (Eclipse Link or Hibernate or ...)
specific implementation </p>
+<p>of the above two interfaces and bind them to the properties. To enable write on
such properties using OData JPA Processor Library, an additional access modifier is required
to be added to the JPA </p>
+<p>entities. Following is the proposal on how OData JPA Processor Library handles java.sql.Blob
and java.sql.Clob during metadata generation and runtime processing. </p>
+<h3 id="edm-generation">EDM Generation</h3>
+<p>Based on the JPA entity property type, the pseudocode for generating the EDM is
as below.</p>
+<p>For java.sql.Blob:</p>
+<ol>
+<li>Check if JPA entity property is of type byte[] or of type java.sql.Blob and annotated
with @Lob annotation. </li>
+<li>If Step 1 is true, then generate an EDM property with type as Edm.Binary</li>
+</ol>
+<p>For java.sql.Clob:</p>
+<ol>
+<li>Check if JPA entity property is of type java.sql.Clob and annotated with @Lob annotation.
</li>
+<li>If Step 1 is true, then generate an EDM property with type as Edm.String (with
no max length unless a max length is specified). </li>
+</ol>
+<h3 id="runtime-processing">Runtime Processing</h3>
+<p><strong>Prerequisite:</strong>
+1. It is mandatory to implement the callback interface org.apache.olingo.odata2.jpa.processor.api.OnJPAWriteContent.
+2. The implemented interface needs to be registered with the service via the method 'setOnJPAWriteContent'
part of 'ODataJPAServiceFactory'. </p>
+<p>Following is the pseudocode for handling the java.sql.Blob and java.sql.Clob during
runtime.</p>
+<div class="codehilite"><pre>    <span class="o">/*</span> <span
class="n">Callback</span> <span class="n">Implementation</span> <span
class="o">*/</span>
+
+    <span class="n">public</span> <span class="n">class</span> <span
class="n">OnDBWriteContent</span> <span class="n">implements</span> <span
class="n">OnJPAWriteContent</span> <span class="p">{</span>
+
+      <span class="p">@</span><span class="n">Override</span>
+      <span class="n">public</span> <span class="n">Blob</span> <span
class="n">getJPABlob</span><span class="p">(</span><span class="n">byte</span><span
class="p">[]</span> <span class="n">binaryData</span><span class="p">)</span>
<span class="n">throws</span> <span class="n">ODataJPARuntimeException</span>
<span class="p">{</span>
+        <span class="k">try</span> <span class="p">{</span>
+          <span class="k">return</span> <span class="n">new</span>
<span class="n">JDBCBlob</span><span class="p">(</span><span class="n">binaryData</span><span
class="p">);</span>
+        <span class="p">}</span> <span class="k">catch</span> <span
class="p">(</span><span class="n">SerialException</span> <span class="n">e</span><span
class="p">)</span> <span class="p">{</span>
+          <span class="n">ODataJPARuntimeException</span><span class="p">.</span><span
class="n">throwException</span><span class="p">(</span><span class="n">ODataJPARuntimeException</span><span
class="p">.</span><span class="n">INNER_EXCEPTION</span><span class="p">,</span>
<span class="n">e</span><span class="p">);</span>
+        <span class="p">}</span> <span class="k">catch</span> <span
class="p">(</span><span class="n">SQLException</span> <span class="n">e</span><span
class="p">)</span> <span class="p">{</span>
+          <span class="n">ODataJPARuntimeException</span><span class="p">.</span><span
class="n">throwException</span><span class="p">(</span><span class="n">ODataJPARuntimeException</span><span
class="p">.</span><span class="n">INNER_EXCEPTION</span><span class="p">,</span>
<span class="n">e</span><span class="p">);</span>
+        <span class="p">}</span>
+        <span class="k">return</span> <span class="n">null</span><span
class="p">;</span>
+      <span class="p">}</span>
+
+      <span class="p">@</span><span class="n">Override</span>
+      <span class="n">public</span> <span class="n">Clob</span> <span
class="n">getJPAClob</span><span class="p">(</span><span class="n">char</span><span
class="p">[]</span> <span class="n">characterData</span><span class="p">)</span>
<span class="n">throws</span> <span class="n">ODataJPARuntimeException</span>
<span class="p">{</span>
+        <span class="k">try</span> <span class="p">{</span>
+          <span class="k">return</span> <span class="n">new</span>
<span class="n">JDBCClob</span><span class="p">(</span><span class="n">new</span>
<span class="n">String</span><span class="p">(</span><span class="n">characterData</span><span
class="p">));</span>
+        <span class="p">}</span> <span class="k">catch</span> <span
class="p">(</span><span class="n">SQLException</span> <span class="n">e</span><span
class="p">)</span> <span class="p">{</span>
+          <span class="n">ODataJPARuntimeException</span><span class="p">.</span><span
class="n">throwException</span><span class="p">(</span><span class="n">ODataJPARuntimeException</span><span
class="p">.</span><span class="n">INNER_EXCEPTION</span><span class="p">,</span>
<span class="n">e</span><span class="p">);</span>
+        <span class="p">}</span>
+          <span class="k">return</span> <span class="n">null</span><span
class="p">;</span>
+        <span class="p">}</span>
+      <span class="p">}</span>
+
+
+    <span class="o">/*</span> <span class="n">Call</span> <span
class="n">Back</span> <span class="n">registration</span> <span class="n">in</span>
<span class="n">Service</span> <span class="n">Factory</span> <span
class="o">*/</span>
+    <span class="n">public</span> <span class="n">class</span> <span
class="n">JPAReferenceServiceFactory</span> <span class="n">extends</span>
<span class="n">ODataJPAServiceFactory</span> <span class="p">{</span>
+
+      <span class="n">public</span> <span class="n">static</span>
<span class="n">final</span> <span class="n">OnJPAWriteContent</span>
<span class="n">onDBWriteContent</span> <span class="p">=</span> <span
class="n">new</span> <span class="n">OnDBWriteContent</span><span
class="p">();</span>
+
+      <span class="p">@</span><span class="n">Override</span>
+      <span class="n">public</span> <span class="n">ODataJPAContext</span>
<span class="n">initializeODataJPAContext</span><span class="p">()</span>
+          <span class="n">throws</span> <span class="n">ODataJPARuntimeException</span>
<span class="p">{</span>
+
+        <span class="p">....</span>
+        <span class="p">........</span>
+        <span class="p">..............</span>
+
+        <span class="n">setOnWriteJPAContent</span><span class="p">(</span><span
class="n">onDBWriteContent</span><span class="p">);</span> <span class="o">//</span><span
class="n">Register</span> <span class="n">Call</span> <span class="n">Back</span>
+
+        <span class="k">return</span> <span class="n">oDataJPAContext</span><span
class="p">;</span>
+       <span class="p">}</span>
+     <span class="p">}</span>
+</pre></div>
+
+
+<p>OData JPA Processor Library internally does the following:
+1. Checks if the JPA entity property is of type java.sql.Blob or java.sql.Clob.
+2. If Step 1 is true, then it invokes the registered callback method 'getJPABlob' or 'getJPAClob'
respectively.
+3. If callback method is not defined, it throws an exception. </p>
+<p><em>Note</em>: Step 3 is needed because the OData JPA Processor Library
is not bound to any specific implementation of Blob or Clob interface. </p>
+            
+            
+            
+            
+            <hr>
+            
+            <footer>                 
+                <div align="center"><p>Copyright © 2013-2014, The Apache Software
Foundation<br>
+                Apache Olingo, Olingo, Apache, the Apache feather, and 
+the Apache Olingo project logo are trademarks of the Apache Software 
+Foundation.</p></div>
+        <hr>
+        <div align="center"><small><a href="http://olingo.staging.apache.org/doc/privacy.html">Privacy</a></small></div>
+            </footer>
+            
+        </div> <!-- /container -->
+        
+        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
+        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>
+        
+        <script src="/js/vendor/bootstrap.min.js"></script>
+        
+        <script src="/js/main.js"></script>
+        
+<script>
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+  ga('create', 'UA-44963757-1', 'apache.org');
+  ga('send', 'pageview');
+
+</script>    </body>
+</html>



Mime
View raw message