@Test public void replaceLegacyQueryParameters() { assertEquals("select column from table where table.column = ?1", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column = ?")); assertEquals("select column from table where table.column =?1", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column =?")); assertEquals("select column from table where table.column =?1 ", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column =? ")); assertEquals("select column from table where table.column in (?1)", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column in (?)")); assertEquals("select column from table where table.column in (?1,?2)", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column in (?,?)")); assertEquals("select column from table where table.column in (?1,?2 )", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column in (?,? )")); assertEquals("select column from table where table.column in ( ?1 , ?2 )", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column in ( ? , ? )")); assertEquals("select column from table where table.column >?1", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column >?")); assertEquals("select column from table where table.column <?1", HqlQueryUtils.replaceLegacyQueryParameters("select column from table where table.column <?")); }
public static String replaceLegacyQueryParameters(String queryString) { String convertedString = queryString; for (int index = 1;; ++index) { Matcher matcher = LEGACY_ORDINAL_PARAMS_PATTERN.matcher(convertedString); if (!matcher.find()) { return convertedString; } StringBuilder builder = new StringBuilder(); builder.append(convertedString, 0, matcher.end(1)); builder.append('?'); builder.append(index); builder.append(convertedString, matcher.start(2), convertedString.length()); convertedString = builder.toString(); } }
HqlQueryUtils { public static String replaceLegacyQueryParameters(String queryString) { String convertedString = queryString; for (int index = 1;; ++index) { Matcher matcher = LEGACY_ORDINAL_PARAMS_PATTERN.matcher(convertedString); if (!matcher.find()) { return convertedString; } StringBuilder builder = new StringBuilder(); builder.append(convertedString, 0, matcher.end(1)); builder.append('?'); builder.append(index); builder.append(convertedString, matcher.start(2), convertedString.length()); convertedString = builder.toString(); } } }
HqlQueryUtils { public static String replaceLegacyQueryParameters(String queryString) { String convertedString = queryString; for (int index = 1;; ++index) { Matcher matcher = LEGACY_ORDINAL_PARAMS_PATTERN.matcher(convertedString); if (!matcher.find()) { return convertedString; } StringBuilder builder = new StringBuilder(); builder.append(convertedString, 0, matcher.end(1)); builder.append('?'); builder.append(index); builder.append(convertedString, matcher.start(2), convertedString.length()); convertedString = builder.toString(); } } private  HqlQueryUtils(); }
HqlQueryUtils { public static String replaceLegacyQueryParameters(String queryString) { String convertedString = queryString; for (int index = 1;; ++index) { Matcher matcher = LEGACY_ORDINAL_PARAMS_PATTERN.matcher(convertedString); if (!matcher.find()) { return convertedString; } StringBuilder builder = new StringBuilder(); builder.append(convertedString, 0, matcher.end(1)); builder.append('?'); builder.append(index); builder.append(convertedString, matcher.start(2), convertedString.length()); convertedString = builder.toString(); } } private  HqlQueryUtils(); static boolean isShortFormStatement(String statement); static boolean isSafe(String statementString); static String replaceLegacyQueryParameters(String queryString); }
HqlQueryUtils { public static String replaceLegacyQueryParameters(String queryString) { String convertedString = queryString; for (int index = 1;; ++index) { Matcher matcher = LEGACY_ORDINAL_PARAMS_PATTERN.matcher(convertedString); if (!matcher.find()) { return convertedString; } StringBuilder builder = new StringBuilder(); builder.append(convertedString, 0, matcher.end(1)); builder.append('?'); builder.append(index); builder.append(convertedString, matcher.start(2), convertedString.length()); convertedString = builder.toString(); } } private  HqlQueryUtils(); static boolean isShortFormStatement(String statement); static boolean isSafe(String statementString); static String replaceLegacyQueryParameters(String queryString);  }