[seam-commits] Seam SVN: r14268 - in branches/community/Seam_2_3: jboss-seam/src/test/java/org/jboss/seam/test/unit and 2 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Jan 26 15:53:08 EST 2012
Author: manaRH
Date: 2012-01-26 15:53:07 -0500 (Thu, 26 Jan 2012)
New Revision: 14268
Modified:
branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Query.java
branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/QueryTest.java
branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/framework/Query.java
branches/community/Seam_2_3/jboss-seam/src/test/java/org/jboss/seam/test/unit/QueryTest.java
Log:
JBSEAM-4854 get correct order in conditions for getting count query
Modified: branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/framework/Query.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/framework/Query.java 2012-01-26 16:19:18 UTC (rev 14267)
+++ branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/framework/Query.java 2012-01-26 20:53:07 UTC (rev 14268)
@@ -300,11 +300,11 @@
int whereLoc = whereMatcher.find() ? whereMatcher.start(1) : groupLoc;
String subject;
- if (getGroupBy() != null) {
- subject = "distinct " + getGroupBy();
- }
- else if (useWildcardAsCountQuerySubject) {
+ if (useWildcardAsCountQuerySubject) {
subject = "*";
+ }
+ else if (getGroupBy() != null) {
+ subject = "distinct " + getGroupBy();
}
// to be JPA-compliant, we need to make this query like "select count(u) from User u"
// however, Hibernate produces queries some databases cannot run when the primary key is composite
Modified: branches/community/Seam_2_3/jboss-seam/src/test/java/org/jboss/seam/test/unit/QueryTest.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/test/java/org/jboss/seam/test/unit/QueryTest.java 2012-01-26 16:19:18 UTC (rev 14267)
+++ branches/community/Seam_2_3/jboss-seam/src/test/java/org/jboss/seam/test/unit/QueryTest.java 2012-01-26 20:53:07 UTC (rev 14268)
@@ -88,6 +88,17 @@
}
}
+
+ @Test
+ public void testCountQueryWithGroupBy()
+ {
+ UnitQuery query = new UnitQuery();
+ query.setEjbql("select min(e.birthYear), count(*) from Person p group by p.birthYear");
+ query.setGroupBy("p.birthYear");
+ query.parseEjbql();
+ assertEquals(query.getCountEjbql() , "select count(*) from Person p");
+
+ }
// class CompliantUnitQuery extends UnitQuery {
//
Modified: branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Query.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Query.java 2012-01-26 16:19:18 UTC (rev 14267)
+++ branches/community/Seam_2_3/jboss-seam-jsf2/src/main/java/org/jboss/seam/framework/Query.java 2012-01-26 20:53:07 UTC (rev 14268)
@@ -300,12 +300,12 @@
int whereLoc = whereMatcher.find() ? whereMatcher.start(1) : groupLoc;
String subject;
- if (getGroupBy() != null) {
- subject = "distinct " + getGroupBy();
- }
- else if (useWildcardAsCountQuerySubject) {
+ if (useWildcardAsCountQuerySubject) {
subject = "*";
}
+ else if (getGroupBy() != null) {
+ subject = "distinct " + getGroupBy();
+ }
// to be JPA-compliant, we need to make this query like "select count(u) from User u"
// however, Hibernate produces queries some databases cannot run when the primary key is composite
else {
Modified: branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/QueryTest.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/QueryTest.java 2012-01-26 16:19:18 UTC (rev 14267)
+++ branches/community/Seam_2_3/jboss-seam-jsf2/src/test/java/org/jboss/seam/test/unit/QueryTest.java 2012-01-26 20:53:07 UTC (rev 14268)
@@ -61,6 +61,17 @@
query.parseEjbql();
assertEquals(query.getCountEjbql(), "select count(p) from Person p");
}
+
+ @Test
+ public void testCountQueryWithGroupBy()
+ {
+ UnitQuery query = new UnitQuery();
+ query.setEjbql("select min(e.birthYear), count(*) from Person p group by p.birthYear");
+ query.setGroupBy("p.birthYear");
+ query.parseEjbql();
+ assertEquals(query.getCountEjbql() , "select count(*) from Person p");
+
+ }
class UnitQuery extends EntityQuery {
More information about the seam-commits
mailing list