<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Object+Translator">Object Translator</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://docs.jboss.org/author/display/~van.halbert">Van Halbert</a>
    </h4>
        <br/>
                         <h4>Changes (11)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h1. {*}Object Translator{*} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >The Object <span class="diff-changed-words">translator<span class="diff-added-chars"style="background-color: #dfd;">, known by the name of _map-cache_,</span></span> is a bridge for reading <span class="diff-added-words"style="background-color: #dfd;">and writing</span> java objects from external sources (i.e., <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Infinispan Cache or</span> Map cache) and delivering them to the engine for processing. &amp;nbsp;And to assist in providing that bridge, the [OBJECTTABLE]&amp;nbsp;function can be used to transform complex java objects into rows and columns. &amp;nbsp;&amp;nbsp; <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The following are the translator types supported by the Object Translator: <br>* _infinispan-cache_&amp;nbsp; <br>* _map-cache_&amp;nbsp; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h2. {*}Search Capabilities{*} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h2. {*}_map-cache_{*} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >Supports a local cache that is of type Map and it uses _key_ searching on the map to find objects. <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* CompareCriteria - only EQ <br>* InCriteria <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">* Insert, Update and Delete <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Currently only supports read only. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h2. {*}_infinispan-cache_{*} <br> <br>Supports Infinispan/JDG cache and has the options for using either DSL searching (JDG 6.3+), Hibernate/Lucene searching, or Key searching (when no indexing is used).   See the [jdg-local-cache|https://docs.jboss.org/author/display/teiidexamples/JBoss+Data+Grid+%28JDG%29+running+in+Library+Mode+as+a+Data+Source+Example] quick start for an example.  Note, this assumes you will be installing JDG into the same server installation, running in library mode. <br> <br>h3. Installation <br>The *infinispan-cache* translator is not configured, out-of-the-box, in the standalone-teiid.xml configuration.  To configure the translator, run the [add-infinispan-cache-translator.cli | https://github.com/teiid/teiid/blob/master/build/kits/jboss-as7/docs/teiid/datasources/infinispan/add-infinispan-cache-translator.cli] script.  This script can also be found in the teiid-jboss-dist.zip kit, under docs/teiid/datasources/infinispan. <br> <br>h3. Execution Properties <br>|| Name || Description || Required || Default || <br>| SupportsLuceneSearching | Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache | No | false | <br>| SupportsDSLSearching | Setting to true assumes your are using JDG v6.3 or better and your cache has indexing enabled | No | false | <br>| SupportsIsNullCriteria | Setting to true assumes [https://issues.jboss.org/browse/TEIID-3573] has been resolved | No | false | <br>| SupportsCompareCriteriaOrdered | Setting to true assumes [https://issues.jboss.org/browse/TEIID-3627] has been resolved | No | false | <br>| SupportsNotCriteria | Setting to true assumes [https://issues.jboss.org/browse/TEIID-3573] has been resolved | No | false | <br> <br>h3. Supported Capabilities <br> <br>The following are the connector capabilities when Key Searching is used: <br>* SELECT command <br>* CompareCriteria - only EQ <br>* InCriteria <br> <br>The following are the connector capabilities when Hibernate/Lucene Searching is enabled: <br>* SELECT command <br>* CompareCriteria - EQ, NE, LT, GT, etc. <br>* And/Or Criteria <br>* In Criteria <br>* Like Criterai <br>* Or Criteria <br>* INSERT, UPDATE, DELETE <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h2. Usage <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;vdb name=&quot;team&quot; version=&quot;1&quot;&gt; <br>    &lt;model name=&quot;Team&quot; visible=&quot;false&quot;&gt; <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">        &lt;source name=&quot;objsource&quot; translator-name=&quot;infinispan1&quot; connection-jndi-name=&quot;java:infinispan-jndi&quot;/&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;source name=&quot;objsource&quot; translator-name=&quot;map-cache&quot; connection-jndi-name=&quot;java:cache-jndi&quot;/&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >        &lt;metadata type=&quot;DDL&quot;&gt;&lt;![CDATA[ <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;/model&gt; <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">    &lt;translator name=&quot;infinispan1&quot; type=&quot;infinispan-cache&quot;&gt; <br>        &lt;property name=&quot;SupportsLuceneSearching&quot; value=&quot;true&quot;/&gt; <br>    &lt;/translator&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >&lt;/vdb&gt; <br>{code} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. {*}JCA Resource Adapter{*} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;"> <br>See the Infinispan Datasources resource adapter for this translator. &amp;nbsp; It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName or RemoteServerList).&amp;nbsp; <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="ObjectTranslator-%7B%7DObjectTranslator%7B%7D"></a><b>Object Translator</b></h1>

<p>The Object translator, known by the name of <em>map-cache</em>, is a bridge for reading and writing java objects from external sources (i.e., Map cache) and delivering them to the engine for processing. &nbsp;And to assist in providing that bridge, the <a href="/author/display/TEIID/OBJECTTABLE" title="OBJECTTABLE">OBJECTTABLE</a>&nbsp;function can be used to transform complex java objects into rows and columns. &nbsp;&nbsp;</p>

<h2><a name="ObjectTranslator-%7B%7DSearchCapabilities%7B%7D"></a><b>Search Capabilities</b></h2>

<p>Supports a local cache that is of type Map and it uses <em>key</em> searching on the map to find objects.</p>

<h3><a name="ObjectTranslator-SupportedCapabilities"></a>Supported Capabilities</h3>

<p>The following are the connector capabilities when Key Searching is used:</p>
<ul>
        <li>SELECT command</li>
        <li>CompareCriteria - only EQ</li>
        <li>InCriteria</li>
        <li>Insert, Update and Delete</li>
</ul>



<h2><a name="ObjectTranslator-Usage"></a>Usage</h2>

<ul>
        <li>Retrieve objects from a cache and transform into rows and columns.</li>
        <li>Perform writes to the cache</li>
</ul>



<h2><a name="ObjectTranslator-Metadata"></a>Metadata</h2>


<h5><a name="ObjectTranslator-DefinitionRequirements"></a>Definition Requirements</h5>

<ul>
        <li>The table for the root class, must have a primary key defined, which must map to an attribute in the class.</li>
        <li>The table "name in source" (NIS) will be the name of the cache this table/class is stored</li>
        <li>The primary object that represents the cached object should have a name in source of 'this'.&nbsp; All other columns will have their name in source (which defaults to the column name) interpreted as the path to the column value from the primary object.</li>
        <li>All columns that are not the primary key nor covered by a lucene index should be marked as SEARCHABLE 'Unsearchable'.</li>
        <li>Attributes defined as repeatable (i.e., collections, arrays, etc.) or a container class, will be supported as 1-to-* relationships, and will have corresponding registered class (if they are to be searched).</li>
        <li>A 1-to-* relationship class must have a foreign key to map to the root class/table, where the name in source for the foreign key is the name of the root class method to access those child objects.  Note, this is the class method, not a reference in the google protobuf definition.</li>
        <li>Dynamic VDBs using metadata import will automatically determine a phsyical table for each root object and will have each top level member represented as a column.</li>
</ul>


<h5><a name="ObjectTranslator-OptionsforDefining"></a>Options for Defining</h5>

<p>The following is an example of a key search and a view that associated player names with their team. It uses a dynamic vdb to define the physical source and views using DDL. &nbsp; It uses a TeamObject class, shown below, with a teamName field that is used as its cache key and a String list of players.&nbsp;</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
public class TeamObject {

   private String teamName;
   private List&lt;String&gt; players = new ArrayList&lt;String&gt;();

   public String getTeamName() {
      return teamName;
   }

   public void setTeamName(String teamName) {
           this.teamName = teamName;
   }

   public List&lt;String&gt; getPlayers() {
           return players;
   }

}
</pre>
</div></div>

<p>Note that by just using a dynamic vdb, the native import logic will provide you with a TeamObject physical table that can be queried.  An equivalent Team table is shown here for demonstration purposes.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: xml; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;vdb name="team" version="1"&gt;
    &lt;model name="Team" visible="false"&gt;
        &lt;source name="objsource" translator-name="map-cache" connection-jndi-name="java:cache-jndi"/&gt;
        &lt;metadata type="DDL"&gt;&lt;![CDATA[

            CREATE FOREIGN TABLE Team (
                TeamObject Object OPTIONS (NAMEINSOURCE 'this', SEARCHABLE 'Unsearchable'),
                teamName varchar(255) PRIMARY KEY)
              OPTIONS (NAMEINSOURCE 'teams');

         ]]&gt; &lt;/metadata&gt;
    &lt;/model&gt;
    &lt;model name="TeamView" type="VIRTUAL"&gt;
         &lt;metadata type="DDL"&gt;&lt;![CDATA[
             CREATE VIEW Players (
                  TeamName varchar(255) PRIMARY KEY,
                  PlayerName varchar(255)
             )
             AS
             SELECT t.TeamName, y.Name FROM Team as T,
                   OBJECTTABLE('m.players' PASSING T.TeamObject as m COLUMNS Name string 'teiid_row') as y;

        ]]&gt; &lt;/metadata&gt;
    &lt;/model&gt;

&lt;/vdb&gt;
</pre>
</div></div>

<p>Notice the use of the <a href="/author/pages/createpage.action?spaceKey=TEIID&amp;title=OBJECTABLE&amp;linkCreation=true&amp;fromPageId=55477048" class="createlink">OBJECTABLE</a>&nbsp;function to parse the object from Team and transform into rows and column. This is only for demonstration purposes, and is not required in order to parse the object into rows and columns.  </p>

<p>This metadata could also be defined by using the Teiid Designer Teiid Connection Importer.</p>

<h3><a name="ObjectTranslator-%7B%7DJCAResourceAdapter%7B%7D"></a><b>JCA Resource Adapter</b></h3>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://docs.jboss.org/author/display/TEIID/Object+Translator">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=55477048&revisedVersion=14&originalVersion=13">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Object+Translator?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>