Author: simoneg
Date: Mon Jan  4 15:08:52 2010
New Revision: 895657

URL: http://svn.apache.org/viewvc?rev=895657&view=rev
Log:
Compute the QBE when counting result, taking into consideration that it could 
contain a FROM clause

Modified:
    
labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java

Modified: 
labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java?rev=895657&r1=895656&r2=895657&view=diff
==============================================================================
--- 
labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
 (original)
+++ 
labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
 Mon Jan  4 15:08:52 2010
@@ -115,27 +115,25 @@
        }
        
        protected int countResults(Database db) {
-               if (this.sessionReservedQbe == null) { 
-                       StringBuilder countquery = new 
StringBuilder(this.query); 
-                       if (!this.query.toLowerCase().startsWith("select")) {
-                               countquery.insert(0, "SELECT COUNT(x) FROM " + 
this.myclass.getName() + " x ");
+               if (this.sessionReservedQbe != null) {
+                       computeQbeQuery();
+               }
+               StringBuilder countquery = new StringBuilder(this.query); 
+               if (!this.query.toLowerCase().startsWith("select")) {
+                       countquery.insert(0, "SELECT COUNT(x) FROM " + 
this.myclass.getName() + " x ");
+               } else {
+                       int index = this.query.toLowerCase().indexOf("from");
+                       if (index == -1) {
+                               countquery = null;
                        } else {
-                               int index = 
this.query.toLowerCase().indexOf("from");
-                               if (index == -1) {
-                                       countquery = null;
-                               } else {
-                                       countquery.delete(0, index);
-                                       countquery.insert(0, "SELECT COUNT(x) 
");
-                               }
-                       }
-                       if (countquery != null) {
-                               return db.queryNumber(countquery.toString(), 
this.queryParams).intValue();
+                               countquery.delete(0, index);
+                               countquery.insert(0, "SELECT COUNT(x) ");
                        }
-                       return -1;
-               } else {
-                       computeQbeQuery();
-                       return db.queryNumber("SELECT COUNT(x) FROM " + 
this.myclass.getName() + " x " + this.query, this.queryParams).intValue();
                }
+               if (countquery != null) {
+                       return db.queryNumber(countquery.toString(), 
this.queryParams).intValue();
+               }
+               return -1;
        }
        
        protected String getOrderBy() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to