Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public class EscapedRestrictions {
  2. public static Criterion ilike(String propertyName, String value) {
  3. return new EscapedILikeExpression(propertyName, value);
  4. }
  5.  
  6. public static Criterion ilike(String propertyName, String value, MatchMode matchMode) {
  7. return new EscapedILikeExpression(propertyName, value, matchMode);
  8. }
  9. }
  10.  
  11. class EscapedILikeExpression extends IlikeExpression {
  12. private static final String HIBERNATE_ESCAPE_CHAR = "\";
  13.  
  14. public EscapedILikeExpression(String propertyName, Object value) {
  15. super(propertyName, value);
  16. }
  17.  
  18. public EscapedILikeExpression(String propertyName, String value, MatchMode matchMode) {
  19. super(propertyName, replaceAll(value), matchMode);
  20. }
  21.  
  22. private static String replaceAll(String value) {
  23. return value
  24. .replace("\", HIBERNATE_ESCAPE_CHAR + "\")
  25. .replace("_", HIBERNATE_ESCAPE_CHAR + "_")
  26. .replace("%", HIBERNATE_ESCAPE_CHAR + "%");
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement