<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+DSL+Translator">Infinispan DSL 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 (3)</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" > <br>There are several options to defining the metadata representing your object in the cache.   <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>* &quot;Recommended&quot; Use the Teiid Connection Importer in Teiid Designer to create the physical source model based on your object cache. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >* Use dynamic VDB that only defines the data source to use.  Example: <br> <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;">* Use Teiid Designer to manually create the physical source model based on your object cache using the above *Usage* patterns.  <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>* Use the Teiid Connection Importer  Teiid Designer to manually create the physical source model based on your object cache using the above  <br>*Usage* patterns. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h2. {*}JCA Resource Adapter{*} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="InfinispanDSLTranslator-%7B%7DInfinispanDSLTranslator%7B%7D"></a><b>Infinispan DSL Translator</b></h1>

<p>The Infinispan DSL Translator, known by the type <b>infinispan-cache-dsl</b>, can read the java objects from a remote Infinispan Cache via the Hot Rod client using the Google Protobuf for serialization.  The benefit of this JDG design is it will enable Teiid to query the cache using DSL, which is similar to doing Lucene searching on a local cache.    If you are using Infinispan in library mode, see the <a href="/author/display/TEIID/Object+Translator" title="Object Translator">Object Translator</a> for this type of configuration.</p>

<p><b>Properties</b></p>

<p>The Infinispan DSL Translator currently has no import or execution properties.  See the JCA resource adapter section below as to how to configure the cache to be queried. </p>

<h2><a name="InfinispanDSLTranslator-Installation"></a>Installation</h2>
<p>The <b>infinispan-cache-dsl</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-dsl-translator.cli" class="external-link" rel="nofollow">add-infinispan-cache-dsl-translator.cli </a> script.  This script can also be found in the teiid-jboss-dist.zip kit, under docs/teiid/datasources/infinispan.   See the <a href="https://docs.jboss.org/author/display/teiidexamples/JBoss+Data+Grid+Remote+Cache+as+a+Data+Source" class="external-link" rel="nofollow">jdg-remote-cache</a> quick start for an example.  Note, this assumes you will be installing a separate JDG server, which will be accessed via the Hot Rod Client installed into the Teiid server.</p>

<h2><a name="InfinispanDSLTranslator-%7B%7DSupportedCapabilities%7B%7D"></a><b>Supported Capabilities</b></h2>

<p>The following are the connector capabilities:</p>
<ul>
        <li>Compare Criteria - EQ, LT, GT, LE, GE.</li>
        <li>And/Or Criteria</li>
        <li>In Criteria</li>
        <li>Like Criteria</li>
        <li>Order By</li>
        <li>INSERT, UPDATE, DELETE (non-transactional)</li>
</ul>


<p>The following will not be pushed down to JDG for processing, but will be done within Teiid:</p>
<ul>
        <li>Not (NE, &lt;&gt;)</li>
        <li>IsNull</li>
</ul>


<p>Limitations:</p>
<ul>
        <li>support for 'Not' has been disabled, because JDG considers &lt;column when null&gt; &lt;&gt; 1 to be true and SQL does not.</li>
        <li>boolean data type:  JDG will throw an exception if no value is specified on the insert or when no default value is defined in the protobuf definition file.</li>
        <li>char data type:  is not a supported type in theProtobuf data types (<a href="https://developers.google.com/protocol-buffers/docs/proto#scalar" class="external-link" rel="nofollow">https://developers.google.com/protocol-buffers/docs/proto#scalar</a>).  Would either have to handle conversion in the protobuf marshaller or create a Teiid view with the data type as char.</li>
        <li>1-to-Many, currently only supports Collection or Array, not Map's'</li>
        <li>Write transactions not supported by JDG when using Hot Rod client</li>
</ul>


<p>To be done:</p>
<ul>
        <li>support deleting containing class(s) (i.e., person --&gt; phones, delete a phone)</li>
        <li>support updating containing class(s)</li>
</ul>


<h2><a name="InfinispanDSLTranslator-%7B%7DUsage%7B%7D"></a><b>Usage</b></h2>

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



<h2><a name="InfinispanDSLTranslator-%7B%7DMetadata%7B%7D"></a><b>Metadata</b></h2>

<h5><a name="InfinispanDSLTranslator-DefinitionRequirements"></a>Definition Requirements</h5>
<ul>
        <li>Each google registered class in the cache will have a corresponding table created.</li>
        <li>The table for the root class, must have a primary key defined, which must map to an attribute in the class.
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>The data type for the attribute in the class must match the JDG cache key data type.</td></tr></table></div></li>
        <li>The table "name in source" (NIS) will be the name of the JDG cache this table/class is stored</li>
        <li>The table columns will be created from the google protobuf definition, that corresponds to a registered class.</li>
        <li>Columns will be identified as SEARCHABLE if either the protobuf definition for a column indicates its indexed or the pojo class has the attribute/method annotated.</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>A container/child class will have attributes where the NIS contain a period.  Example:  phone.number<br/>
   This is because this maps to to google protobuf definition and what is expected to be used in the DSL query.</li>
</ul>


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

<p>There are several options to defining the metadata representing your object in the cache.  </p>

<ul>
        <li>"Recommended" Use the Teiid Connection Importer in Teiid Designer to create the physical source model based on your object cache.</li>
</ul>


<ul>
        <li>Use dynamic VDB that only defines the data source to use.  Example:</li>
</ul>


<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;model name="People" type="Physical"&gt;
        &lt;property name="importer.useFullSchemaName" value="false"/&gt;
           
        &lt;source name="infinispan-cache-dsl-connector" translator-name="infinispan-cache-dsl" connection-jndi-name="java:/infinispanRemoteDSL" /&gt;
    &lt;/model&gt;
</pre>
</div></div>

<p>The metadata will be resolved by reverse engineering the defined object in the cache.  This can be useful when using the Teiid Designer Teiid Connection Importer for building the physical source model(s).</p>

<ul>
        <li>Use dynamic VDB, but you define the metadata using DDL.</li>
</ul>


<p>Note, this also shows a container class, PhoneNumber, as an example of the foreign key that's defines the relationship.</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="PeopleVDB" version="1"&gt;
    &lt;model name="People" visible="true"&gt;
        &lt;property name="importer.useFullSchemaName" value="false"/&gt;
       
        &lt;source name="infinispan-cache-dsl-connector" translator-name="infinispan-cache-dsl" connection-jndi-name="java:/infinispanRemote" /&gt;

        &lt;metadata type="DDL"&gt;&lt;![CDATA[

 CREATE FOREIGN TABLE Person (
        PersonObject object OPTIONS (NAMEINSOURCE 'this', UPDATABLE FALSE, SEARCHABLE 'Unsearchable', NATIVE_TYPE 'java.lang.Object'),
        id integer NOT NULL OPTIONS (SEARCHABLE 'Searchable', NATIVE_TYPE 'int'),
        name string OPTIONS (SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        email string OPTIONS (SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        CONSTRAINT PK_ID PRIMARY KEY(id)
) OPTIONS (NAMEINSOURCE 'PersonsCache', UPDATABLE TRUE);

CREATE FOREIGN TABLE PhoneNumber (
        number string OPTIONS (NAMEINSOURCE 'phone.number', SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        type string OPTIONS (NAMEINSOURCE 'phone.type', SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        id integer NOT NULL OPTIONS (SELECTABLE FALSE, UPDATABLE FALSE, SEARCHABLE 'Searchable', NATIVE_TYPE 'int'),
        CONSTRAINT FK_PERSON FOREIGN KEY(id) REFERENCES Person (id) OPTIONS (NAMEINSOURCE 'phones')
) OPTIONS (NAMEINSOURCE 'PersonsCache', UPDATABLE TRUE);

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

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



<ul>
        <li>Use the Teiid Connection Importer  Teiid Designer to manually create the physical source model based on your object cache using the above<br/>
<b>Usage</b> patterns.</li>
</ul>


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

<p>See the Infinispan-DSL resource adapter for this translator. &nbsp; It can be configured to lookup the cache container via JNDI, server list, or hot rod properties..&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+DSL+Translator">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=81855155&revisedVersion=13&originalVersion=12">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Infinispan+DSL+Translator?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>