[jboss-user] [JBoss Seam] - Re: org.jboss.seam.framework Query too case sensitive
codelion
do-not-reply at jboss.com
Tue Jan 23 04:43:16 EST 2007
Had no luck with diff against CVS with Eclipse on Windows, neither with TortoiseCVS. Probably a line-feed on platform problem. Then tried WinCVS. Is this a good format?
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/Query.java,v
| retrieving revision 1.14
| diff -u -w -b -r1.14 Query.java
| --- Query.java 16 Dec 2006 14:06:58 -0000 1.14
| +++ Query.java 23 Jan 2007 09:22:35 -0000
| @@ -3,6 +3,8 @@
| import java.util.ArrayList;
|
| import java.util.List;
|
| import java.util.StringTokenizer;
|
| +import java.util.regex.Matcher;
| +import java.util.regex.Pattern;
|
|
| import javax.faces.model.DataModel;
|
|
|
| @@ -34,6 +36,11 @@
| public abstract Object getSingleResult();
|
| public abstract Long getResultCount();
|
|
|
| + private static final Pattern FROM_PATTERN =
| + Pattern.compile("[^a-z0-9_](from)[^a-z0-9_]", Pattern.CASE_INSENSITIVE);
| + private static final Pattern ORDER_PATTERN =
| + Pattern.compile("[^a-z0-9_](order)[^a-z0-9_]", Pattern.CASE_INSENSITIVE);
| +
| @Create
|
| public void validate()
|
| {
|
| @@ -205,9 +212,15 @@
| protected String getCountEjbql()
|
| {
|
| String ejbql = getRenderedEjbql();
|
| - int fromLoc = ejbql.indexOf("from");
|
| - int orderLoc = ejbql.indexOf("order");
|
| - if (orderLoc<0) orderLoc = ejbql.length();
|
| +
| + Matcher fromMatcher = FROM_PATTERN.matcher(ejbql);
| + boolean foundFrom = fromMatcher.find();
| + int fromLoc = fromMatcher.start(1);
| +
| + Matcher orderMatcher = ORDER_PATTERN.matcher(ejbql);
| + boolean foundOrder = orderMatcher.find();
| + int orderLoc = foundOrder ? orderMatcher.start(1) : ejbql.length();
| +
| return "select count(*) " + ejbql.substring(fromLoc, orderLoc);
|
| }
I'll be happy to write it up in JIRA (first report problem then supply this solution) if this is an acceptable format. Let me know.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4005219#4005219
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4005219
More information about the jboss-user
mailing list