@@ -18,18 +18,48 @@ public class InterceptorParamBuilder<P extends BasicJpa, J extends BasicJson, E>
1818 private String orderByClause = "" ;
1919 private String query = "" ;
2020
21+ /**
22+ * This helps you to add something to the select-clause, like 'distinct' or a
23+ * limit.<br>
24+ * The standard table always gets the alias 'o'.
25+ *
26+ * @param selectClause the clause (Example:
27+ * {@code 'DISTINCT ' + ThisJpa.class.getSimpleName + ' AS o'})
28+ * @return itself in order to provide a fluent interface.
29+ */
2130 public InterceptorParamBuilder <P , J , E > select (final String selectClause ) {
22- this .selectClause = selectClause ;
31+ this .selectClause = selectClause .trim ().toLowerCase ().startsWith ("select" )
32+ ? selectClause .trim ().substring (6 ).trim ()
33+ : selectClause .trim ();
2334 return this ;
2435 }
2536
37+ /**
38+ * Here you can specify a special join-clause that will be added to your query
39+ * later on.<br>
40+ * The aliases you give here may be used in all other parts of the query.
41+ *
42+ * @param joinClause the clause (Example:
43+ * {@code ' JOIN ' + MyClass.getSimpleName() + ' AS f ON o.fId=f.id'})
44+ * @return itself in order to provide a fluent interface.
45+ */
2646 public InterceptorParamBuilder <P , J , E > join (final String joinClause ) {
27- this .joinClause = joinClause . startsWith ( " " ) ? joinClause : " " + joinClause ;
47+ this .joinClause = " " + joinClause . trim () ;
2848 return this ;
2949 }
3050
51+ /**
52+ * Here you can specify a special order-by-clause that will be appended to your
53+ * SQL-query later on.
54+ * <p>
55+ * May or may not start with 'order by', your choice.
56+ *
57+ * @param orderByClause the clause (Example: {@code 'o.name DESC'}
58+ * @return itself in order to provide a fluent interface.
59+ */
3160 public InterceptorParamBuilder <P , J , E > orderBy (final String orderByClause ) {
32- this .orderByClause = orderByClause .startsWith (" " ) ? orderByClause : " " + orderByClause ;
61+ this .orderByClause = orderByClause .trim ().toLowerCase ().startsWith ("order by" ) ? " " + orderByClause .trim ()
62+ : " ORDER BY " + orderByClause .trim ();
3363 return this ;
3464 }
3565
@@ -52,7 +82,7 @@ public InterceptorParamBuilder<P, J, E> orderBy(final String orderByClause) {
5282 * preceded by a '~'.<br>
5383 * {@code Example: 'dbEnumField = :jsonField[~MyEnumClass]'}<br>
5484 * <p>
55- * - Term operators are: >, <, >=, <=, = or ==, <> or != and LIKE (which
85+ * - Term operators are: {@code >, <, >=, <=, = or ==, <> or != and LIKE} (which
5686 * automatically adds the wildcards like %yourvalue% before going to the
5787 * database).<br>
5888 * - Every term may be optional when you precede the DB-field-name with a
@@ -69,6 +99,12 @@ public InterceptorParamBuilder<P, J, E> query(final String query) {
6999 return this ;
70100 }
71101
102+ /**
103+ * Builds this Interceptor and returns you to the fluent interface of the
104+ * underlying {@link GenericHandlerGroupBuilder}.
105+ *
106+ * @return the {@link GenericHandlerGroupBuilder} you came from.
107+ */
72108 public GenericHandlerGroupBuilder <P , J , E > build () {
73109 InterceptorData r = InterceptorData .builder ()
74110 .selectClause (selectClause )
0 commit comments