@@ -113,6 +113,34 @@ interface Augmentation<T> {
113
113
114
114
/**
115
115
* Add an {@linkplain Augmentation augmentation} to the specification.
116
+ * <p>
117
+ * For example:
118
+ * <pre>
119
+ * SelectionSpecification.create(Book.class)
120
+ * .addAugmentation((builder, query, book) ->
121
+ * // augment the query via JPA Criteria API
122
+ * query.where(builder.like(book.get(Book_.title), titlePattern)),
123
+ * builder.greaterThan(book.get(Book_.pages), minPages))
124
+ * .orderBy(builder.asc(book.get(Book_.isbn)))
125
+ * .createQuery(session)
126
+ * .getResultList();
127
+ * </pre>
128
+ * For complicated cases, a {@link org.hibernate.query.criteria.CriteriaDefinition}
129
+ * may be used within an augmentation to eliminate repetitive explicit references to
130
+ * the {@link CriteriaBuilder}.
131
+ * <pre>
132
+ * SelectionSpecification.create(Book.class)
133
+ * .addAugmentation((builder, query, book) ->
134
+ * // eliminate explicit references to 'builder'
135
+ * new CriteriaDefinition<>(query) {{
136
+ * where(like(entity.get(BasicEntity_.title), titlePattern),
137
+ * greaterThan(book.get(Book_.pages), minPages));
138
+ * orderBy(asc(book.get(Book_.isbn)));
139
+ * }}
140
+ * )
141
+ * .createQuery(session)
142
+ * .getResultList();
143
+ * </pre>
116
144
*
117
145
* @param augmentation A function capable of modifying or augmenting a criteria query.
118
146
*
0 commit comments