<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/~shawkins">Steven Hawkins</a>
    </h4>
        <br/>
                         <h4>Changes (23)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h1. {color:#000000}{*}Object Translator{*}{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h1. {*}Object Translator{*} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>The</span> Object translator is a bridge for reading java objects from external sources (i.e., Infinispan Cache or Map cache) and delivering them to the engine for processing. &amp;nbsp;And to assist in providing that bridge, the <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span>[OBJECTTABLE]&amp;nbsp;function</span> must be used to transform the java object into rows and columns. &amp;nbsp;&amp;nbsp; <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>The</span> following are the translator types and their respective supported data <span class="diff-changed-words">source:<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" >* _infinispan-cache_&amp;nbsp;\- supports Infinispan cache and using either Key searching (for non-annotated objects) or Hibernate/Lucene searching <br>* _map-cache_&amp;nbsp;\- supports a local cache that is of type Map and using Key searching <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}{*}Execution Properties&amp;nbsp;\- infinispan-cache{*}{color} <br>|| {color:#000000}Name{color} || {color:#000000}Description{color} || {color:#333333}Required{color} || {color:#000000}Default{color} || <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{*}Execution Properties&amp;nbsp;\- infinispan-cache{*} <br>|| Name || Description || Required || Default || <br></td></tr>
            <tr><td class="diff-changed-lines" >| <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}SupportsLuceneSearching{color}</span> <span class="diff-added-words"style="background-color: #dfd;">SupportsLuceneSearching</span> | <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>Setting</span> to true assumes your objects are annotated and Hibernate/Lucene will be used to search the <span class="diff-changed-words">cache<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span></span> | <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}N{color}</span> <span class="diff-added-words"style="background-color: #dfd;">N</span> | <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}false{color}</span> <span class="diff-added-words"style="background-color: #dfd;">false</span> | <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;">h3. {color:#000000}{*}Supported Capabilities{*}{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. {*}Supported Capabilities{*} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>The</span> following are the connector capabilities when Key Searching is <span class="diff-changed-words">used:<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" >* SELECT command <br>* CompareCriteria - only EQ <br>* InCriteria <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>The</span> following are the connector capabilities when Hibernate/Lucene Searching is <span class="diff-changed-words">enabled:<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" >* SELECT command <br>* CompareCriteria - EQ, NE, LT, GT, etc. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* OrCriteria <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >h3. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#000000}{*}Usage{*}{color}</span> <span class="diff-added-words"style="background-color: #dfd;">{*}Usage{*}</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>Retrieve</span> objects from a cache and transform into rows and <span class="diff-changed-words">columns.<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" >* The primary object returned by the cache should have a name in source of &#39;this&#39;.&amp;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. <br>* All columns that are not the primary key nor covered by a lucene index should be marked as SEARCHABLE &#39;Unsearchable&#39;. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">* 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.  <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;">{color:#333333}The following is an example of a key search. It uses a dynamic vdb to define the physical source and views using DDL. &amp;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.&amp;nbsp;{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">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. &amp;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.&amp;nbsp; <br></td></tr>
            <tr><td class="diff-unchanged" >{code:java} <br>public class TeamObject { <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >} <br>{code} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}Notice the use of the {color}{color:#005e8f}\[{color}{color:#005e8f}OBJECTABLE{color}\|TEIID:OBJECTABLE\]&amp;nbsp;function to parse the object from Team and transform into rows and column. This metadata could also be defined by using Teiid Designer.&amp;nbsp;&amp;nbsp; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>Note that by just using a dynamic vdb native import logic will provide you with a TeamObject physical table.  An equivalent Team table is shown here for demonstration purposes. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{code:xml} <br>&lt;vdb name=&quot;team&quot; version=&quot;1&quot;&gt; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">   </span> &lt;property name=&quot;UseConnectorMetadata&quot; value=&quot;cached&quot; /&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;model name=&quot;Team&quot; visible=&quot;false&quot;&gt; <br>        &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-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3. {color:#000000}{*}JCA Resource Adapter{*}{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Notice the use of the [OBJECTABLE|TEIID:OBJECTABLE]&amp;nbsp;function to parse the object from Team and transform into rows and column. This metadata could also be defined by using Teiid Designer.&amp;nbsp; <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. {*}JCA Resource Adapter{*} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>See</span> the Infinispan resource adapter for this translator. &amp;nbsp; It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName or <span class="diff-changed-words">RemoteServerList).&amp;nbsp;<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span></span> <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 is a bridge for reading java objects from external sources (i.e., Infinispan Cache or 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 must be used to transform the java object into rows and columns. &nbsp;&nbsp;</p>

<p>The following are the translator types and their respective supported data source:</p>
<ul>
        <li><em>infinispan-cache</em>&nbsp;&#45; supports Infinispan cache and using either Key searching (for non-annotated objects) or Hibernate/Lucene searching</li>
        <li><em>map-cache</em>&nbsp;&#45; supports a local cache that is of type Map and using Key searching</li>
</ul>


<p><b>Execution Properties&nbsp;&#45; infinispan-cache</b></p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default </th>
</tr>
<tr>
<td class='confluenceTd'> SupportsLuceneSearching </td>
<td class='confluenceTd'> Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> false </td>
</tr>
</tbody></table>
</div>


<h3><a name="ObjectTranslator-%7B%7DSupportedCapabilities%7B%7D"></a><b>Supported Capabilities</b></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>
</ul>


<p>The following are the connector capabilities when Hibernate/Lucene Searching is enabled:</p>
<ul>
        <li>SELECT command</li>
        <li>CompareCriteria - EQ, NE, LT, GT, etc.</li>
        <li>InCriteria</li>
        <li>OrCriteria</li>
</ul>


<h3><a name="ObjectTranslator-%7B%7DUsage%7B%7D"></a><b>Usage</b></h3>

<p>Retrieve objects from a cache and transform into rows and columns.</p>
<ul>
        <li>The primary object returned by the cache 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>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>


<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 native import logic will provide you with a TeamObject physical table.  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;property name="UseConnectorMetadata" value="cached" /&gt;
    &lt;model name="Team" visible="false"&gt;
        &lt;source name="objsource" translator-name="infinispan1" connection-jndi-name="java:infinispan-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;translator name="infinispan1" type="infinispan-cache"&gt;
        &lt;property name="SupportsLuceneSearching" value="true"/&gt;
    &lt;/translator&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 metadata could also be defined by using Teiid Designer.&nbsp;</p>

<h3><a name="ObjectTranslator-%7B%7DJCAResourceAdapter%7B%7D"></a><b>JCA Resource Adapter</b></h3>

<p>See the Infinispan resource adapter for this translator. &nbsp; It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName or RemoteServerList).&nbsp;</p>
    </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=4&originalVersion=3">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>