<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 (4)</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>{warning} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">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 [Override Execution Properties|Translators#Override Execution Properties] above. <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 execution property|Translators#Override Execution Properties] called &quot;SupportsNativeQueries&quot; to true. <br></td></tr>
            <tr><td class="diff-unchanged" >{warning} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">JPA translator provides a procedure with name *native* 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&#39;s execution results are not known to the Teiid and they are returned as object array. User can use [ARRAYTABLE] to construct a build a tabular output for consumption by client applications. Teiid exposes this procedure with a simple query structure as below <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The JPA translator provides a procedure with name *native* 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&#39;s results are not known to Teiid, they are returned as object array. User can use [ARRAYTABLE] can be used construct tabular output for consumption by client applications. Teiid exposes this procedure with a simple query structure as below <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h5. Select <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="JPATranslator-JPATranslator"></a>JPA Translator</h1>

<p>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.</p>

<h3><a name="JPATranslator-NativeQueries"></a>Native Queries</h3>

<p>JPA source procedures may be created using the teiid_rel:native-query extension - see&nbsp;<a href="/author/display/TEIID/Translators#Translators-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, <a href="/author/display/TEIID/Translators#Translators-OverrideExecutionProperties">override the execution property</a> called "SupportsNativeQueries" to true.</td></tr></table></div>

<p>The JPA translator provides a procedure with name <b>native</b> 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 results are not known to Teiid, they are returned as object array. User can use <a href="/author/display/TEIID/ARRAYTABLE" title="ARRAYTABLE">ARRAYTABLE</a> can be used construct tabular output for consumption by client applications. Teiid exposes this procedure with a simple query structure as below</p>

<h5><a name="JPATranslator-Select"></a>Select</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>from the above code, the "search" keyword followed by a query statement - see <a href="/author/display/TEIID/Translators#Translators-native">Parameterizable Native Queries</a> to substitute parameter values.</p>

<h5><a name="JPATranslator-Delete"></a>Delete</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>form the above code, the "delete" keyword followed by JPA-QL for delete operation.</p>

<h5><a name="JPATranslator-Update"></a>Update</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>form the above code, the "update" keyword must be followed by JPA-QL for the update statement.</p>

<h5><a name="JPATranslator-Create"></a>Create</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>Create operation needs to send "create" word as marker and send the entity as a the first parameter.</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>By default the name of the procedure that executes the queries directly is called <b>native</b>, however user can set <a href="/author/display/TEIID/Translators#Translators-OverrideExecutionProperties">Override Execution Properties</a> property on <em>NativeQueryProcedureName</em> in vdb.xml file to change it to any other procedure name.</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=5&originalVersion=4">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>