Author: norman.richards(a)jboss.com
Date: 2008-02-06 15:08:42 -0500 (Wed, 06 Feb 2008)
New Revision: 7388
Modified:
trunk/src/main/org/jboss/seam/framework-2.1.xsd
trunk/src/main/org/jboss/seam/framework/Query.java
Log:
JBSEAM-2302
Modified: trunk/src/main/org/jboss/seam/framework/Query.java
===================================================================
--- trunk/src/main/org/jboss/seam/framework/Query.java 2008-02-06 19:11:17 UTC (rev 7387)
+++ trunk/src/main/org/jboss/seam/framework/Query.java 2008-02-06 20:08:42 UTC (rev 7388)
@@ -26,9 +26,9 @@
public abstract class Query<T, E>
extends PersistenceController<T> //TODO: extend MutableController!
{
- private static final Pattern FROM_PATTERN =
Pattern.compile("(^|\\s)(from)\\s", Pattern.CASE_INSENSITIVE);
+ private static final Pattern FROM_PATTERN =
Pattern.compile("(^|\\s)(from)\\s", Pattern.CASE_INSENSITIVE);
+ private static final Pattern WHERE_PATTERN =
Pattern.compile("\\s(where)\\s", Pattern.CASE_INSENSITIVE);
private static final Pattern ORDER_PATTERN =
Pattern.compile("\\s(order)(\\s)+by\\s", Pattern.CASE_INSENSITIVE);
- private static final Pattern WHERE_PATTERN =
Pattern.compile("\\s(where)\\s", Pattern.CASE_INSENSITIVE);
private static final Pattern ORDER_COLUMN_PATTERN =
Pattern.compile("^\\w*$");
@@ -43,6 +43,8 @@
private String orderColumn;
private String orderDirection;
+ private String groupBy;
+
private DataModel dataModel;
private String parsedEjbql;
@@ -247,9 +249,15 @@
builder.append( parsedRestrictions.get(i) );
}
}
-
- if ( getOrder()!=null ) builder.append(" order by ").append( getOrder()
);
+ if (getGroupBy()!=null) {
+ builder.append(" group by ").append(getGroupBy());
+ }
+
+ if (getOrder()!=null) {
+ builder.append(" order by ").append( getOrder() );
+ }
+
return builder.toString();
}
@@ -362,6 +370,16 @@
refresh();
}
+
+
+ public String getGroupBy() {
+ return groupBy;
+ }
+
+ public void setGroupBy(String groupBy) {
+ this.groupBy = groupBy;
+ }
+
/**
* The order clause of the query
*/
@@ -371,6 +389,8 @@
if (column == null) {
return order;
+
+
}
String direction = getOrderDirection();
Modified: trunk/src/main/org/jboss/seam/framework-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/framework-2.1.xsd 2008-02-06 19:11:17 UTC (rev 7387)
+++ trunk/src/main/org/jboss/seam/framework-2.1.xsd 2008-02-06 20:08:42 UTC (rev 7388)
@@ -18,12 +18,14 @@
<xs:attribute name="ejbql" type="xs:string"/>
<xs:attribute name="max-results" type="xs:integer"/>
<xs:attribute name="order" type="xs:string"/>
+ <xs:attribute name="group-by" type="xs:string"/>
</xs:attributeGroup>
<xs:element name="restrictions"
type="components:multiValuedProperty"/>
<xs:element name="hints" type="components:mapProperty"/>
<xs:element name="ejbql" type="xs:string"/>
<xs:element name="order" type="xs:string"/>
+ <xs:element name="group-by" type="xs:string"/>
<xs:element name="entity-query">
<xs:complexType mixed="true">
@@ -31,6 +33,7 @@
<xs:element minOccurs="0" maxOccurs="1"
ref="framework:ejbql"/>
<xs:element minOccurs="0" maxOccurs="1"
ref="framework:order"/>
<xs:element minOccurs="0" maxOccurs="1"
ref="framework:restrictions"/>
+ <xs:element minOccurs="0" maxOccurs="1"
ref="framework:group-by"/>
<xs:element minOccurs="0" maxOccurs="1"
ref="framework:hints"/>
</xs:choice>
<xs:attributeGroup ref="components:attlist.component"/>
@@ -47,6 +50,7 @@
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element minOccurs="0" maxOccurs="1"
ref="framework:ejbql"/>
<xs:element minOccurs="0" maxOccurs="1"
ref="framework:order"/>
+ <xs:element minOccurs="0" maxOccurs="1"
ref="framework:group-by"/>
<xs:element minOccurs="0" maxOccurs="1"
ref="framework:restrictions"/>
</xs:choice>
<xs:attributeGroup ref="components:attlist.component"/>
Show replies by date