Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting incorrect result from Hibernate\Oracle
    text
    copied!<p>Tomcat: 5.5<br> Oracle: 11G(11.1.0.7.4)<br> JDK: 1.6<br> Hibernate: 3.0.5 </p> <p><strong>The context</strong><br> We are using Hibernate to get rowcount on a view. The view is written in a way that it will always get at least one row. In the database, there are enough rows for the view to return 8 rows.</p> <p><strong>The problem</strong><br> Once in a while, we get count as ZERO</p> <p>If we try again (i.e the user refreshes screen) correct count of 8 is returned.</p> <p><strong>Investigation</strong><br> We have tried bunch of things to rule out the following</p> <p>1) Oracle server returning a bad result<br> 2) Checked the view to make sure it is is good i.e will return correct result</p> <p>Now the suspicion is turning towards Hibernate</p> <p><strong>The code snippet</strong><br> Can you spot anything suspicious in the code below ?</p> <pre><code>public static int getRowCount( Criteria criteria ) { int totalRows = 0; criteria.setProjection( Projections.rowCount() ); Integer count = ( Integer ) criteria.uniqueResult(); if ( count != null ) totalRows = count.intValue(); criteria.setProjection( null ); criteria.setResultTransformer( Criteria.ROOT_ENTITY ); return totalRows; } </code></pre> <p>We have also verified that the count is zero and not null<br> Bizarre as it may sound, there are published Oracle defects where it returns incorrect results and moreover this error started happening when we applied an Oracle hot fix.</p> <p><strong>Question</strong><br> Does anyone think it's possible that Oracle could be returning incorrect result?<br> Any suggestion on how to troubleshoot this would be appreciated as well...</p> <p><strong>Summary of some key facts</strong><br> - Started happening about the same time when we upgraded Oracle11G from 11.1.0.6.1 to 11.1.0.7.4 and did some hot fixes.<br> - This was the only change that happened to ecosystem during that time frame- Changes to Oracle<br> - This happens inconsistently. Now you see the problem- Now you don't.<br> - Infrequent. But serious enough to cause alarms. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload