[jboss-user] [JBoss Seam] - Re: org.jboss.seam.framework Query too case sensitive
codelion
do-not-reply at jboss.com
Thu Jan 18 08:00:30 EST 2007
Here is my code. I'll try again with CVS, I've figured out anonymous CVS for Seam, I've figured out you want JIRA to submit diff, but both with TortoiseCVS and with Eclipse (to a Windows machine) I'm getting double line breaks, so my diff is wrong. I try again in a couple of days.
Meanwhile so the suspense doesn't become unbearable...
import java.util.regex.Matcher;
| import java.util.regex.Pattern;
|
| 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);
|
| protected String getCountEjbql() {
| String ejbql = getRenderedEjbql();
| //
| 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);
| }
These patterns could use some more research, but now they prevent mismatches for tokens named orderForm and fromAddress, and they're case-insensitive.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003285#4003285
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003285
More information about the jboss-user
mailing list