@Test public final void shouldCreateAliasForTwoLevelDeepPath() { String field = "firstBelongsTo.secondBelongsTo.fieldName"; GridComponentFilterUtils.addAliases(criteria, field, JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo", "firstBelongsTo_a", JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo_a.secondBelongsTo", "secondBelongsTo_a", JoinType.LEFT); }
public static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType) { if (field == null) { return null; } String[] path = field.split("\\."); if (path.length == 1) { return field; } String lastAlias = ""; for (int i = 0; i < path.length - 1; i++) { criteria.createAlias(lastAlias + path[i], path[i] + "_a", joinType); lastAlias = path[i] + "_a."; } return lastAlias + path[path.length - 1]; }
GridComponentFilterUtils { public static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType) { if (field == null) { return null; } String[] path = field.split("\\."); if (path.length == 1) { return field; } String lastAlias = ""; for (int i = 0; i < path.length - 1; i++) { criteria.createAlias(lastAlias + path[i], path[i] + "_a", joinType); lastAlias = path[i] + "_a."; } return lastAlias + path[path.length - 1]; } }
GridComponentFilterUtils { public static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType) { if (field == null) { return null; } String[] path = field.split("\\."); if (path.length == 1) { return field; } String lastAlias = ""; for (int i = 0; i < path.length - 1; i++) { criteria.createAlias(lastAlias + path[i], path[i] + "_a", joinType); lastAlias = path[i] + "_a."; } return lastAlias + path[path.length - 1]; } private  GridComponentFilterUtils(); }
GridComponentFilterUtils { public static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType) { if (field == null) { return null; } String[] path = field.split("\\."); if (path.length == 1) { return field; } String lastAlias = ""; for (int i = 0; i < path.length - 1; i++) { criteria.createAlias(lastAlias + path[i], path[i] + "_a", joinType); lastAlias = path[i] + "_a."; } return lastAlias + path[path.length - 1]; } private  GridComponentFilterUtils(); static void addFilters(final Map<String, String> filters, final Map<String, GridComponentColumn> columns,
            final DataDefinition dataDefinition, final SearchCriteriaBuilder criteria); static void addMultiSearchFilter(GridComponentMultiSearchFilter multiSearchFilter,
            Map<String, GridComponentColumn> columns, DataDefinition dataDefinition, SearchCriteriaBuilder criteria); static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType); static String getFieldNameByColumnName(final Map<String, GridComponentColumn> columns, final String columnName); }
GridComponentFilterUtils { public static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType) { if (field == null) { return null; } String[] path = field.split("\\."); if (path.length == 1) { return field; } String lastAlias = ""; for (int i = 0; i < path.length - 1; i++) { criteria.createAlias(lastAlias + path[i], path[i] + "_a", joinType); lastAlias = path[i] + "_a."; } return lastAlias + path[path.length - 1]; } private  GridComponentFilterUtils(); static void addFilters(final Map<String, String> filters, final Map<String, GridComponentColumn> columns,
            final DataDefinition dataDefinition, final SearchCriteriaBuilder criteria); static void addMultiSearchFilter(GridComponentMultiSearchFilter multiSearchFilter,
            Map<String, GridComponentColumn> columns, DataDefinition dataDefinition, SearchCriteriaBuilder criteria); static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType); static String getFieldNameByColumnName(final Map<String, GridComponentColumn> columns, final String columnName);  }