http://git-wip-us.apache.org/repos/asf/isis-site/blob/97af7e5f/content/guides/htg.html
----------------------------------------------------------------------
diff --git a/content/guides/htg.html b/content/guides/htg.html
index cff02f1..ab534cd 100644
--- a/content/guides/htg.html
+++ b/content/guides/htg.html
@@ -243,6 +243,7 @@ table.CodeRay td.code>pre{padding:0}
        </div> 
       </form> 
      </div> 
+     <p class="nav navbar-text navbar-right small">v1.16.1</p> 
     </div> 
    </div> 
   </nav> 
@@ -412,7 +413,7 @@ table.CodeRay td.code>pre{padding:0}
             <p>A third alternative is to move the responsibility for deriving 
the title into a separate subscriber object.</p> 
            </div> 
            <div class="paragraph"> 
-            <p>In the target object, we define an appropriate event type and 
use the <a 
href="../rgant/rgant.html#_rgant_DomainObjectLayout_titleUiEvent"><code>@DomainObjectLayout#titleUiEvent()</code></a>
 attribute to specify:</p> 
+            <p>In the target object, we define an appropriate event type and 
use the <a 
href="../rgant/rgant.html#_rgant-DomainObjectLayout_titleUiEvent"><code>@DomainObjectLayout#titleUiEvent()</code></a>
 attribute to specify:</p> 
            </div> 
            <div class="listingblock"> 
             <div class="content"> 
@@ -523,7 +524,7 @@ table.CodeRay td.code>pre{padding:0}
             <p>As for title, the determination of which image file to use for 
the icon can be externalized into a UI event subscriber.</p> 
            </div> 
            <div class="paragraph"> 
-            <p>In the target object, we define an appropriate event type and 
use the <a 
href="../rgant/rgant.html#_rgant_DomainObjectLayout_iconUiEvent"><code>@DomainObjectLayout#iconUiEvent()</code></a>
 attribute to specify.</p> 
+            <p>In the target object, we define an appropriate event type and 
use the <a 
href="../rgant/rgant.html#_rgant-DomainObjectLayout_iconUiEvent"><code>@DomainObjectLayout#iconUiEvent()</code></a>
 attribute to specify.</p> 
            </div> 
            <div class="paragraph"> 
             <p>For example</p> 
@@ -619,7 +620,7 @@ table.CodeRay td.code>pre{padding:0}
             <p>As for title and icon, the determination of which CSS class to 
render can be externalized into a UI event subscriber.</p> 
            </div> 
            <div class="paragraph"> 
-            <p>In the target object, we define an appropriate event type and 
use the <a 
href="../rgant/rgant.html#_rgant_DomainObjectLayout_cssClassUiEvent"><code>@DomainObjectLayout#cssClassUiEvent()</code></a>
 attribute to specify.</p> 
+            <p>In the target object, we define an appropriate event type and 
use the <a 
href="../rgant/rgant.html#_rgant-DomainObjectLayout_cssClassUiEvent"><code>@DomainObjectLayout#cssClassUiEvent()</code></a>
 attribute to specify.</p> 
            </div> 
            <div class="paragraph"> 
             <p>For example</p> 
@@ -938,7 +939,7 @@ table.CodeRay td.code>pre{padding:0}
           </div> 
          </div> 
          <div class="paragraph"> 
-          <p>For this we annotate the collection using <a 
href="../rgant/rgant.html#_rgant_CollectionLayout_defaultView"><code>@CollectionLayout#defaultView()</code></a>;
 for example</p> 
+          <p>For this we annotate the collection using <a 
href="../rgant/rgant.html#_rgant-CollectionLayout_defaultView"><code>@CollectionLayout#defaultView()</code></a>;
 for example</p> 
          </div> 
          <div class="listingblock"> 
           <div class="content"> 
@@ -960,7 +961,7 @@ table.CodeRay td.code>pre{padding:0}
              <td class="icon"> <i class="fa icon-note" title="Note"></i> </td> 
              <td class="content"> 
               <div class="paragraph"> 
-               <p>The <code>defaultView()</code> attribute replaces the 
deprecated approach of using <a 
href="../rgant/rgant.html#_rgant_CollectionLayout_render"><code>@CollectionLayout#render()</code></a>
 eagerly.</p> 
+               <p>The <code>defaultView()</code> attribute replaces the 
deprecated approach of using <a 
href="../rgant/rgant.html#_rgant-CollectionLayout_render"><code>@CollectionLayout#render()</code></a>
 eagerly.</p> 
               </div> </td> 
             </tr> 
            </tbody>
@@ -1804,6 +1805,96 @@ findCustomer.get({<span class="key">queryString</span>: 
JSON.stringify(findCusto
           </table> 
          </div> 
         </div> 
+        <div class="sect2"> 
+         <h3 id="_ugodn_hints-and-tips_jdoql-and-timestamps">4.6. JDOQL and 
Timestamps</h3> 
+         <div class="paragraph"> 
+          <p>Beware of entities with a property called "timestamp": you run 
the risk of "timestamp" being treated as a keyword in certain contexts, 
probably not as you intended.</p> 
+         </div> 
+         <div class="paragraph"> 
+          <p>By way of example, the (non-ASF) <a 
href="http://platform.incode.org";>Incode Platform</a>'s command module has an 
entity called <code>CommandJdo</code>. This has a property called "timestamp", 
of type <code>java.sql.Timestamp</code>.</p> 
+         </div> 
+         <div class="paragraph"> 
+          <p>This defines a query using JDOQL:</p> 
+         </div> 
+         <div class="listingblock"> 
+          <div class="content"> 
+           <pre class="CodeRay highlight"><code data-lang="java">SELECT
+FROM org.isisaddons.module.command.dom.CommandJdo
+WHERE executeIn == <span class="string"><span class="delimiter">'</span><span 
class="content">FOREGROUND</span><span class="delimiter">'</span></span>
+   &amp;&amp; timestamp &gt; :timestamp
+   &amp;&amp; startedAt != <span class="predefined-constant">null</span>
+   &amp;&amp; completedAt != <span class="predefined-constant">null</span>
+ORDER BY timestamp ASC</code></pre> 
+          </div> 
+         </div> 
+         <div class="paragraph"> 
+          <p>This is declared using a JDO <code>@Query</code>; no errors are 
thrown at any stage.</p> 
+         </div> 
+         <div class="paragraph"> 
+          <p>However, running this query against SQL Server 2016 produced a 
different result first time it was run compared to subsequent times.</p> 
+         </div> 
+         <div class="paragraph"> 
+          <p>Running SQL Profiler showed the underlying SQL as:</p> 
+         </div> 
+         <div class="listingblock"> 
+          <div class="content"> 
+           <pre class="CodeRay highlight"><code data-lang="sql">exec 
sp_prepexec <span class="variable">@p1</span> output,<span class="string"><span 
class="modifier">N</span><span class="delimiter">'</span><span 
class="content">@P0 datetime2</span><span class="delimiter">'</span></span>,
+<span class="string"><span class="modifier">N</span><span 
class="delimiter">'</span><span class="content">SELECT 
''org.isisaddons.module.command.dom.CommandJdo'' AS NUCLEUS_TYPE, A0.arguments, 
..., A0.target, A0."timestamp", A0.transactionId, A0."user", ''2018-01-24 
17:29:18.3'' AS NUCORDER0 <i class="conum" data-value="1"></i><b>(1)</b> FROM 
isiscommand.Command A0 WHERE A0.executeIn = ''FOREGROUND'' AND A0."timestamp" 
&gt; @P0 AND A0.startedAt IS NOT NULL AND A0.completedAt IS NOT NULL ORDER BY 
NUCORDER0 OFFSET 0 ROWS FETCH NEXT 2 ROWS ONLY </span><span 
class="delimiter">'</span></span>,   <i class="conum" 
data-value="2"></i><b>(2)</b>
+<span class="string"><span class="delimiter">'</span><span 
class="content">2018-01-24 17:29:18.3000000</span><span 
class="delimiter">'</span></span>               <i class="conum" 
data-value="3"></i><b>(3)</b></code></pre> 
+          </div> 
+         </div> 
+         <div class="colist arabic"> 
+          <table> 
+           <tbody>
+            <tr> 
+             <td><i class="conum" data-value="1"></i><b>1</b></td> 
+             <td>discussed below …​ this is the issue</td> 
+            </tr> 
+            <tr> 
+             <td><i class="conum" data-value="2"></i><b>2</b></td> 
+             <td>because the query is submitted with max rows programmatically 
set to 2.</td> 
+            </tr> 
+            <tr> 
+             <td><i class="conum" data-value="3"></i><b>3</b></td> 
+             <td>argument for @P0 (the timestamp parametr)</td> 
+            </tr> 
+           </tbody>
+          </table> 
+         </div> 
+         <div class="paragraph"> 
+          <p>To unpick this, the key issue is the <code>NUCORDER0</code> 
column, which is then used in the <code>ORDER BY</code>. However, because this 
is a literal value, the effect is no defined ordering.</p> 
+         </div> 
+         <div class="paragraph"> 
+          <p>The problem therefore is that in the JDOQL the "ORDER BY 
timestamp ASC", the "timestamp" is being evaluated as the current time - a 
built-in function.</p> 
+         </div> 
+         <div class="paragraph"> 
+          <p>My fix was to change the JDOQL to be:</p> 
+         </div> 
+         <div class="listingblock"> 
+          <div class="content"> 
+           <pre class="CodeRay highlight"><code data-lang="sql"><span 
class="class">SELECT</span>
+<span class="keyword">FROM</span> org.isisaddons.module.command.dom.CommandJdo
+<span class="keyword">WHERE</span> executeIn == <span class="string"><span 
class="delimiter">'</span><span class="content">FOREGROUND</span><span 
class="delimiter">'</span></span>
+   &amp;&amp; <span class="predefined-type">timestamp</span> &gt; :<span 
class="predefined-type">timestamp</span>
+   &amp;&amp; startedAt != <span class="predefined-constant">null</span>
+   &amp;&amp; completedAt != <span class="predefined-constant">null</span>
+<span class="keyword">ORDER</span> <span class="keyword">BY</span> 
this.timestamp <span class="directive">ASC</span>             <i class="conum" 
data-value="1"></i><b>(1)</b></code></pre> 
+          </div> 
+         </div> 
+         <div class="colist arabic"> 
+          <table> 
+           <tbody>
+            <tr> 
+             <td><i class="conum" data-value="1"></i><b>1</b></td> 
+             <td>Use "this." to qualify the timestamp</td> 
+            </tr> 
+           </tbody>
+          </table> 
+         </div> 
+         <div class="paragraph"> 
+          <p>It wasn’t necessary to qualify the other occurances of 
"timestamp" (though it would be no harm to do so, either).</p> 
+         </div> 
+        </div> 
        </div> 
       </div> 
       <div class="sect1"> 
@@ -3066,7 +3157,7 @@ 
serviceRegistry.injectServicesInto(viewModel);</code></pre>
           <p>If working from the Maven command line, JDO enhancement is done 
using the <code>maven-datanucleus-plugin</code>.</p> 
          </div> 
          <div class="paragraph"> 
-          <p>Both the <a 
href="ugfun.html#_ugfun_getting-started_helloworld-archetype">HelloWorld</a> 
and <a 
href="ugfun.html#_ugfun_getting-started_simpleapp-archetype">SimpleApp</a> 
Maven archetypes generate applications that have this plugin 
pre-configured.</p> 
+          <p>Both the <a 
href="../ugfun/ugfun.html#_ugfun_getting-started_helloworld-archetype">HelloWorld</a>
 and <a 
href="../ugfun/ugfun.html#_ugfun_getting-started_simpleapp-archetype">SimpleApp</a>
 Maven archetypes generate applications that have this plugin 
pre-configured.</p> 
          </div> 
          <div class="sect3"> 
           <h4 id="_meta_inf_persistence_xml">7.1.1. 
META-INF/persistence.xml</h4> 
@@ -3233,7 +3324,7 @@ 
serviceRegistry.injectServicesInto(viewModel);</code></pre>
   <footer class="footer"> 
    <div class="container"> 
     <div class="row"> 
-     <p class="text-center small text-muted"> Copyright © 2010~2017 The 
Apache&nbsp;Software&nbsp;Foundation, licensed under the 
Apache&nbsp;License,&nbsp;v2.0. <br> Apache, the Apache feather logo, 
Apache&nbsp;Isis, and the Apache&nbsp;Isis project logo are all trademarks of 
The&nbsp;Apache&nbsp;Software&nbsp;Foundation. </p> 
+     <p class="text-center small text-muted"> Copyright © 2010~2018 The 
Apache&nbsp;Software&nbsp;Foundation, licensed under the 
Apache&nbsp;License,&nbsp;v2.0. <br> Apache, the Apache feather logo, 
Apache&nbsp;Isis, and the Apache&nbsp;Isis project logo are all trademarks of 
The&nbsp;Apache&nbsp;Software&nbsp;Foundation. </p> 
     </div> 
    </div> 
   </footer> 

Reply via email to