DATACMNS-363 - Support unicode characters in in query method names.

Modified the regex for prefix_template and keyword_template in PartTree in order to support arbitrary unicode characters. Before that change we didn't support unicode correctly since we assumed that a character would have a lower and upper case representation which is often not the case, e.g. in chinese.

Original pull request: #41.
This commit is contained in:
Thomas Darimont
2013-08-27 13:51:51 +02:00
committed by Oliver Gierke
parent 8def493b23
commit f7679d41b8
2 changed files with 19 additions and 2 deletions

View File

@@ -34,11 +34,13 @@ import org.springframework.util.StringUtils;
* each query execution.
*
* @author Oliver Gierke
* @author Thomas Darimont
*/
public class PartTree implements Iterable<OrPart> {
private static final Pattern PREFIX_TEMPLATE = Pattern.compile("^(find|read|get|count)(\\p{Lu}.*?)??By");
private static final String KEYWORD_TEMPLATE = "(%s)(?=\\p{Lu})";
private static final Pattern PREFIX_TEMPLATE = Pattern
.compile("^(find|read|get|count)((\\p{Lu}|\\P{M}\\p{M}*+).*?)??By");
private static final String KEYWORD_TEMPLATE = "(%s)(?=(\\p{Lu}|\\P{M}\\p{M}*+))";
/**
* The subject, for example "findDistinctUserByNameOrderByAge" would have the subject "DistinctUser".