<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/JPA+Translator">JPA 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. {color:#000000}{*}Native Queries{*}{color} <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>JPA</span> source procedures may be created using the teiid_rel:native-query extension - <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">see&amp;nbsp;{color}{color:#005e8f}[{color:#005e8f}Parameterizable</span> <span class="diff-added-words"style="background-color: #dfd;">see&amp;nbsp;[Parameterizable</span> Native <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Queries{color}|#native]{color}{color:#333333}.</span> <span class="diff-added-words"style="background-color: #dfd;">Queries|Built-in Translators#native].</span> The procedure will invoke the native-query similar to an native procedure call with the benefits that the query is predetermined and that result column types are known, rather than requiring the use of ARRAYTABLE or similar <span class="diff-changed-words">functionality.<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" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h4. {color:#000000}{*}Native Procedure{*}{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h4. *Native Procedure* <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{warning} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called &quot;SupportsNativeQueries&quot; to true. Look for&amp;nbsp;{color}{color:#005e8f}[{color:#005e8f}Override Execution Properties{color}|#Override Execution Properties]{color}{color:#333333}&amp;nbsp;above.{color}{warning} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called &quot;SupportsNativeQueries&quot; to true. Look for&amp;nbsp;[Override Execution Properties|Built-in Translators#Override Execution Properties]&amp;nbsp;above.{warning} <br></td></tr>
            <tr><td class="diff-changed-lines" >{color:#333333}JPA translator provides a procedure with <span class="diff-changed-words">name&amp;nbsp;{color}{color:#333333}{*}native{*}{color}<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>&amp;nbsp;that</span> gives ability to execute any ad-hoc native JPA-QL queries directly against the source without any Teiid parsing or resolving. Since the metadata of this procedure&#39;s execution results are not known to the Teiid and they are returned as object array. User can <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">use&amp;nbsp;{color}{color:#005e8f}[{color:#005e8f}ARRAYTABLE{color}|ARRAYTABLE]{color}{color:#333333}&amp;nbsp;to</span> <span class="diff-added-words"style="background-color: #dfd;">use&amp;nbsp;[ARRAYTABLE]&amp;nbsp;to</span> construct a build a tabular output for consumption by client applications. Teiid exposes this procedure with a simple query structure as <span class="diff-changed-words">below<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" > <br></td></tr>
            <tr><td class="diff-changed-lines" >h5. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#000000}{*}Select{*}{color}</span> <span class="diff-added-words"style="background-color: #dfd;">{*}Select{*}</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code:lang=SQL|title=Select Example} <br>SELECT x.* FROM (call pm1.native(&#39;search;FROM Account&#39;)) w, <br> ARRAYTABLE(w.tuple COLUMNS &quot;id&quot; string , &quot;type&quot; string, &quot;name&quot; String) AS x <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" >{color:#333333}from the above code, the &quot;{color}{color:#333333}{*}search{*}{color}{color:#333333}&quot; keyword followed by a query statement - <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">see&amp;nbsp;{color}{color:#005e8f}[{color:#005e8f}Parameterizable</span> <span class="diff-added-words"style="background-color: #dfd;">see&amp;nbsp;{color}{color:#333333}[Parameterizable</span> Native <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Queries{color}|#native]{color}{color:#333333}&amp;nbsp;to</span> <span class="diff-added-words"style="background-color: #dfd;">Queries|Built-in Translators#native]{color}{color:#333333}&amp;nbsp;to</span> substitute parameter values.{color} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >h5. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#000000}{*}Delete{*}{color}</span> <span class="diff-added-words"style="background-color: #dfd;">{*}Delete{*}</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code:lang=SQL|title=Delete Example} <br>SELECT x.* FROM (call pm1.native(&#39;delete;&lt;jpa-ql&gt;&#39;)) w, <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{color:#333333}form the above code, the &quot;{color}{color:#333333}{*}delete{*}{color}{color:#333333}&quot; keyword followed by JPA-QL for delete operation.{color} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >h5. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#000000}{*}Update{*}{color}</span> <span class="diff-added-words"style="background-color: #dfd;">{*}Update{*}</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code:lang=SQL|title=Create Example} <br>SELECT x.* FROM <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="JPATranslator-"></a><font color="#000000"><b>JPA Translator</b></font></h1>

<p><font color="#333333">Think this one as a reverse to what Hibernate provides. If you have JPA based store and have a supporting object model, this translator can will reverse your object model into relational model, where you can integrate with other relational or non-relational sources.</font></p>

<h3><a name="JPATranslator-"></a><font color="#000000"><b>Native Queries</b></font></h3>

<p>JPA source procedures may be created using the teiid_rel:native-query extension - see&nbsp;<a href="/author/display/TEIID/Built-in+Translators#Built-inTranslators-native">Parameterizable Native Queries</a>. The procedure will invoke the native-query similar to an native procedure call with the benefits that the query is predetermined and that result column types are known, rather than requiring the use of ARRAYTABLE or similar functionality.</p>

<h4><a name="JPATranslator-NativeProcedure"></a><b>Native Procedure</b></h4>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called "SupportsNativeQueries" to true. Look for&nbsp;<a href="/author/display/TEIID/Built-in+Translators#Built-inTranslators-OverrideExecutionProperties">Override Execution Properties</a>&nbsp;above.</td></tr></table></div>
<p><font color="#333333">JPA translator provides a procedure with name&nbsp;</font><font color="#333333"><b>native</b></font>&nbsp;that gives ability to execute any ad-hoc native JPA-QL queries directly against the source without any Teiid parsing or resolving. Since the metadata of this procedure's execution results are not known to the Teiid and they are returned as object array. User can use&nbsp;<a href="/author/display/TEIID/ARRAYTABLE" title="ARRAYTABLE">ARRAYTABLE</a>&nbsp;to construct a build a tabular output for consumption by client applications. Teiid exposes this procedure with a simple query structure as below</p>

<h5><a name="JPATranslator-%7B%7DSelect%7B%7D"></a><b>Select</b></h5>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Select Example</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
SELECT x.* FROM (call pm1.native('search;FROM Account')) w,
 ARRAYTABLE(w.tuple COLUMNS "id" string , "type" string, "name" String) AS x
</pre>
</div></div>
<p><font color="#333333">from the above code, the "</font><font color="#333333"><b>search</b></font><font color="#333333">" keyword followed by a query statement - see&nbsp;</font><font color="#333333"><a href="/author/display/TEIID/Built-in+Translators#Built-inTranslators-native">Parameterizable Native Queries</a></font><font color="#333333">&nbsp;to substitute parameter values.</font></p>

<h5><a name="JPATranslator-%7B%7DDelete%7B%7D"></a><b>Delete</b></h5>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Delete Example</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
SELECT x.* FROM (call pm1.native('delete;&lt;jpa-ql&gt;')) w,
 ARRAYTABLE(w.tuple COLUMNS "updatecount" integer) AS x
</pre>
</div></div>
<p><font color="#333333">form the above code, the "</font><font color="#333333"><b>delete</b></font><font color="#333333">" keyword followed by JPA-QL for delete operation.</font></p>

<h5><a name="JPATranslator-%7B%7DUpdate%7B%7D"></a><b>Update</b></h5>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Create Example</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
SELECT x.* FROM
 (call pm1.native('update;&lt;jpa-ql&gt;')) w,
 ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
</pre>
</div></div>
<p><font color="#333333">form the above code, the "</font><font color="#333333"><b>update</b></font><font color="#333333">" keyword must be followed by JPA-QL for the update statement.</font></p>

<h5><a name="JPATranslator-"></a><font color="#000000"><b>Create</b></font></h5>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Update Example</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
SELECT x.* FROM
 (call pm1.native('create;', &lt;entity&gt;)) w,
 ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
</pre>
</div></div>
<p><font color="#333333">Create operation needs to send "</font><font color="#333333"><b>create</b></font><font color="#333333">" word as marker and send the entity as a the first parameter.</font></p>
<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><font color="#333333">By default the name of the procedure that executes the queries directly is called&nbsp;</font><font color="#333333"><b>native</b></font><font color="#333333">, however user can</font><br/>
<font color="#333333">set override execution property vdb.xml file to change it.</font></td></tr></table></div>
    </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/JPA+Translator">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=55477046&revisedVersion=2&originalVersion=1">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/JPA+Translator?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>