NativeContainsExp implements NativeExp { String escapeAndWrapValue(String value) { String escaped = value.replace("%", "\\%").replace("_", "\\_"); return "%" + escaped + "%"; } NativeContainsExp(String columnName, String value); @Override String toSQL(); @Override void setValues(NativeQuery query);  }
@Test public void testEscapeAndWrapValue() { String value = "% __ %"; NativeContainsExp nativeContainsExp = new NativeContainsExp("fortest", value); String expResult = "%\\% \\_\\_ \\%%"; System.out.println(expResult); String result = nativeContainsExp.escapeAndWrapValue(value); assertEquals(expResult, result); }