Revision: 8087
Author: amitman...@google.com
Date: Tue May 11 05:49:29 2010
Log: Added a countExpenses method to the Expenses entity.

Patch by: amitmanjhi
Review by: rjrjr (TBR)

Review at http://gwt-code-reviews.appspot.com/507801

http://code.google.com/p/google-web-toolkit/source/detail?r=8087

Modified:
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/server/domain/Expense.java

=======================================
--- /branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/server/domain/Expense.java Sat May 1 07:18:49 2010 +++ /branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/server/domain/Expense.java Tue May 11 05:49:29 2010
@@ -34,6 +34,15 @@
 @Entity
 public class Expense {

+  public static long countExpenses() {
+    EntityManager em = entityManager();
+    try {
+ return ((Number) em.createQuery("select count(o) from Expense o").getSingleResult()).longValue();
+    } finally {
+      em.close();
+    }
+  }
+
   public static final EntityManager entityManager() {
     return EMF.get().createEntityManager();
   }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to