details:   /erp/devel/pi/rev/eb86e4c97fe5
changeset: 7564:eb86e4c97fe5
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Mon Jun 07 20:12:45 2010 +0200
summary:   fixes issue 13509: In a OBCriteria you can't use list() after a 
count() call

diffstat:

 src-test/org/openbravo/test/dal/IssuesTest.java |  17 +++++++++++++++++
 src/org/openbravo/dal/service/OBCriteria.java   |   4 +++-
 2 files changed, 20 insertions(+), 1 deletions(-)

diffs (47 lines):

diff -r b282c7c51f4d -r eb86e4c97fe5 
src-test/org/openbravo/test/dal/IssuesTest.java
--- a/src-test/org/openbravo/test/dal/IssuesTest.java   Mon Jun 07 15:33:42 
2010 +0200
+++ b/src-test/org/openbravo/test/dal/IssuesTest.java   Mon Jun 07 20:12:45 
2010 +0200
@@ -101,6 +101,9 @@
  * https://issues.openbravo.com/view.php?id=13283: [REST] use organization of 
the object to
  * retrieved referenced objects
  * 
+ * https://issues.openbravo.com/view.php?id=13509: In a OBCriteria you can't 
use list() after a
+ * count() call
+ * 
  * @author mtaal
  * @author iperdomo
  */
@@ -433,4 +436,18 @@
     final Order order = (Order) result.get(0);
     assertTrue(order.getOrganization().getId().equals("1000000"));
   }
+
+  /**
+   * https://issues.openbravo.com/view.php?id=13509: In a OBCriteria you can't 
use list() after a
+   * count() call
+   */
+  public void test13509() throws Exception {
+    setBigBazaarAdminContext();
+    final OBCriteria<Organization> orgs = 
OBDal.getInstance().createCriteria(Organization.class);
+    final int cnt = orgs.count();
+    assertTrue(cnt > 0);
+    final Organization org = orgs.list().get(0);
+    assertTrue(null != org);
+    assertTrue(cnt == orgs.list().size());
+  }
 }
\ No newline at end of file
diff -r b282c7c51f4d -r eb86e4c97fe5 
src/org/openbravo/dal/service/OBCriteria.java
--- a/src/org/openbravo/dal/service/OBCriteria.java     Mon Jun 07 15:33:42 
2010 +0200
+++ b/src/org/openbravo/dal/service/OBCriteria.java     Mon Jun 07 20:12:45 
2010 +0200
@@ -99,7 +99,9 @@
     initialize();
     setProjection(Projections.rowCount());
     log.debug("Counting using criteria " + toString());
-    return ((Number) uniqueResult()).intValue();
+    final int result = ((Number) uniqueResult()).intValue();
+    setProjection(null);
+    return result;
   }
 
   /**

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to