<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/Infinispan+Cache+Translator">Infinispan Cache 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 (10)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. Execution Properties <br>|| Name || Description || Required || Default || <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">| SupportsLuceneSearching | Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache | No | false |  <br></td></tr>
            <tr><td class="diff-changed-lines" >| SupportsDSLSearching | Setting to true assumes your are using JDG v6.3 or better and your cache has indexing enabled | <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">N</span> <span class="diff-added-words"style="background-color: #dfd;">No</span> | false | <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">| SupportsLuceneSearching (deprecated) | Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache | N | false | <br>| SupportsNotCriteria | Setting to true enabled support of NOT operators like &#39;&lt;&#39; or &#39;&lt;&#39; | N | false | <br></td></tr>
            <tr><td class="diff-changed-lines" >| SupportsIsNullCriteria | Setting to true <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">enabled support of IsNull criteria</span> <span class="diff-added-words"style="background-color: #dfd;">assumes [https://issues.jboss.org/browse/TEIID-3539] has been resolved</span> | <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">N</span> <span class="diff-added-words"style="background-color: #dfd;">No</span> | false | <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">| SupportsCompareCriteriaOrdered | Setting to true enables support for criteria with the &#39;=&gt;&#39; or &#39;&lt;=&#39; | N | false | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">| 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></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >SupportsNotCriteria defaults to false because the testing of _column_ &lt;&gt; 1 returns true when the _column_ is null, which isn&#39;t correct by SQL <span class="diff-changed-words">standards<span class="diff-added-chars"style="background-color: #dfd;"> - see [https://issues</span>.<span class="diff-added-chars"style="background-color: #dfd;">jboss.org/browse/TEIID-3573].</span></span>  <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;"> </span> There is an enhancement coming that will enable adding &quot;_column_ IS NOT NULL&quot; when _column_ &lt;&gt; 1 type criteria is detected. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >SupportsIsNullCriteria defaults to false because Infinispan/JDG has an issue with issuing a IS NULL check on a numeric type <span class="diff-changed-words">attribute<span class="diff-added-chars"style="background-color: #dfd;"> - see [https://issues</span>.<span class="diff-added-chars"style="background-color: #dfd;">jboss.org/browse/TEIID-3539].</span></span>  <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;"> </span> Set this to true if you need this check and can control which non-numeric columns that this will be issued against. <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;">SupportsCompareCriteriaOrdered defaults to false because the &#39;=&gt;&#39; and &#39;&lt;=&#39; operations are dependent upon SupportsNotCriteria being enabled.  If this is to be enabled, will also need to enable SupportsNotCritera.  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">SupportsCompareCriteriaOrdered defaults to false because the Infinispan/JDG has an issue with string comparisons - see [https://issues.jboss.org/browse/TEIID-3627]. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-unchanged" >h3. Supported Capabilities <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="InfinispanCacheTranslator-%7B%7DInfinispanCacheTranslator%7B%7D"></a><b>Infinispan Cache Translator</b></h1>

<p>The Infinispan translator, known by the name of <em>infinispan-cache</em>, is a bridge for reading and writing java objects to/from an Infinispan/JDG Cache.  &nbsp;This translator extends the <a href="/author/display/TEIID/Object+Translator" title="Object Translator">Object Translator</a> and uses it for the core processing of reading and writing objects.   The Infinispan Cache Translator is written so that it can control how the cache is searched and any capabilities that are needed to control that behavior. </p>


<h2><a name="InfinispanCacheTranslator-%7B%7DSearchingCapabilities%7B%7D"></a><b><em>Searching Capabilities</em></b></h2>

<p>Supports the options for using either DSL searching (JDG 6.3+), Hibernate/Lucene searching (now deprecated), or Key searching (when no indexing is used).   See the <a href="https://docs.jboss.org/author/display/teiidexamples/JBoss+Data+Grid+%28JDG%29+running+in+Library+Mode+as+a+Data+Source+Example" class="external-link" rel="nofollow">jdg-local-cache</a> quick start for an example.  Note, this assumes you will be installing JDG into the same server installation, running in library mode.</p>

<h3><a name="InfinispanCacheTranslator-Installation"></a>Installation</h3>
<p>The <b>infinispan-cache</b> translator is not configured, out-of-the-box, in the standalone-teiid.xml configuration.  To configure the translator, run the <a href="https://github.com/teiid/teiid/blob/master/build/kits/jboss-as7/docs/teiid/datasources/infinispan/add-infinispan-cache-translator.cli" class="external-link" rel="nofollow">add-infinispan-cache-translator.cli </a> script.  This script can also be found in the teiid-jboss-dist.zip kit, under docs/teiid/datasources/infinispan.</p>

<h3><a name="InfinispanCacheTranslator-ExecutionProperties"></a>Execution Properties</h3>
<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'> No </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> SupportsDSLSearching </td>
<td class='confluenceTd'> Setting to true assumes your are using JDG v6.3 or better and your cache has indexing enabled </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> SupportsIsNullCriteria </td>
<td class='confluenceTd'> Setting to true assumes <a href="https://issues.jboss.org/browse/TEIID-3539" class="external-link" rel="nofollow">https://issues.jboss.org/browse/TEIID-3539</a> has been resolved </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> SupportsCompareCriteriaOrdered </td>
<td class='confluenceTd'> Setting to true assumes <a href="https://issues.jboss.org/browse/TEIID-3627" class="external-link" rel="nofollow">https://issues.jboss.org/browse/TEIID-3627</a> has been resolved </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> SupportsNotCriteria </td>
<td class='confluenceTd'> Setting to true assumes <a href="https://issues.jboss.org/browse/TEIID-3573" class="external-link" rel="nofollow">https://issues.jboss.org/browse/TEIID-3573</a> has been resolved </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> false </td>
</tr>
</tbody></table>
</div>


<p>SupportsNotCriteria defaults to false because the testing of <em>column</em> &lt;&gt; 1 returns true when the <em>column</em> is null, which isn't correct by SQL standards - see <a href="https://issues.jboss.org/browse/TEIID-3573" class="external-link" rel="nofollow">https://issues.jboss.org/browse/TEIID-3573</a>.  There is an enhancement coming that will enable adding "<em>column</em> IS NOT NULL" when <em>column</em> &lt;&gt; 1 type criteria is detected.</p>

<p>SupportsIsNullCriteria defaults to false because Infinispan/JDG has an issue with issuing a IS NULL check on a numeric type attribute - see <a href="https://issues.jboss.org/browse/TEIID-3539" class="external-link" rel="nofollow">https://issues.jboss.org/browse/TEIID-3539</a>.  Set this to true if you need this check and can control which non-numeric columns that this will be issued against.</p>

<p>SupportsCompareCriteriaOrdered defaults to false because the Infinispan/JDG has an issue with string comparisons - see <a href="https://issues.jboss.org/browse/TEIID-3627" class="external-link" rel="nofollow">https://issues.jboss.org/browse/TEIID-3627</a>.</p>

<h3><a name="InfinispanCacheTranslator-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>
</ul>


<p>The following are the connector capabilities when DSL Searching is enabled:</p>
<ul>
        <li>SELECT command</li>
        <li>CompareCriteria - EQ, NE</li>
        <li>CompareCriteria - GT, LT, GE, and LE can be enabled, see Execution Properties</li>
        <li>And/Or Criteria</li>
        <li>In Criteria</li>
        <li>Like Criteria</li>
        <li>Or Criteria</li>
        <li>IsNull check -  see Execution Properties</li>
        <li>Not (negation) - example:  Not In, Not Like</li>
        <li>INSERT, UPDATE, DELETE</li>
</ul>



<h2><a name="InfinispanCacheTranslator-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="InfinispanCacheTranslator-Metadata"></a>Metadata</h2>


<h5><a name="InfinispanCacheTranslator-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 build the physical table for the root object and will have each top level member represented as a column.</li>
</ul>


<h5><a name="InfinispanCacheTranslator-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="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=94961813" 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="InfinispanCacheTranslator-%7B%7DJCAResourceAdapter%7B%7D"></a><b>JCA Resource Adapter</b></h3>

<p>See the Infinispan Datasources resource adapter for this translator. &nbsp; It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName (deprecated) 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/Infinispan+Cache+Translator">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=94961813&revisedVersion=2&originalVersion=1">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Infinispan+Cache+Translator?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>