This repository was archived by the owner on Oct 13, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/io/ebean/typequery Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55 <groupId >io.ebean</groupId >
66 <artifactId >ebean-querybean</artifactId >
7- <version >11.42.2 -SNAPSHOT</version >
7+ <version >11.43.1 -SNAPSHOT</version >
88
99 <parent >
1010 <groupId >org.avaje</groupId >
2323 <dependency >
2424 <groupId >io.ebean</groupId >
2525 <artifactId >ebean</artifactId >
26- <version >11.41 .1</version >
26+ <version >11.43 .1</version >
2727 <scope >provided</scope >
2828 </dependency >
2929
Original file line number Diff line number Diff line change @@ -160,6 +160,39 @@ public R filterMany(ExpressionList<T> filter) {
160160 return _root ;
161161 }
162162
163+ /**
164+ * Apply a filter when fetching these beans.
165+ * <p>
166+ * The expressions can use any valid Ebean expression and contain
167+ * placeholders for bind values using <code>?</code> or <code>?1</code> style.
168+ * </p>
169+ *
170+ * <pre>{@code
171+ *
172+ * new QCustomer()
173+ * .name.startsWith("Postgres")
174+ * .contacts.filterMany("firstName istartsWith ?", "Rob")
175+ * .findList();
176+ *
177+ * }</pre>
178+ *
179+ * <pre>{@code
180+ *
181+ * new QCustomer()
182+ * .name.startsWith("Postgres")
183+ * .contacts.filterMany("whenCreated inRange ? to ?", startDate, endDate)
184+ * .findList();
185+ *
186+ * }</pre>
187+ *
188+ * @param expressions The expressions including and, or, not etc with ? and ?1 bind params.
189+ * @param params The bind parameter values
190+ */
191+ public R filterMany (String expressions , Object ... params ) {
192+ expr ().filterMany (_name , expressions , params );
193+ return _root ;
194+ }
195+
163196 /**
164197 * Is empty for a collection property.
165198 * <p>
Original file line number Diff line number Diff line change 2323import javax .sql .DataSource ;
2424import java .sql .Connection ;
2525import java .sql .SQLException ;
26+ import java .time .LocalDate ;
2627import java .util .ArrayList ;
2728import java .util .Arrays ;
2829import java .util .Collections ;
@@ -288,6 +289,28 @@ public void testFindOne() {
288289 .findList ();
289290 }
290291
292+ @ Test
293+ public void testFilterMany () {
294+
295+ Customer cust = new Customer ();
296+ cust .setName ("Postgres Foo" );
297+ cust .setStatus (Customer .Status .GOOD );
298+ cust .save ();
299+
300+ new QCustomer ()
301+ .name .startsWith ("Postgres" )
302+ .contacts .filterMany ("firstName istartsWith ?" , "Rob" )
303+ .findList ();
304+
305+ final LocalDate startDate = LocalDate .now ().minusDays (7 );
306+ final LocalDate endDate = LocalDate .now ();
307+
308+ new QCustomer ()
309+ .name .startsWith ("Postgres" )
310+ .contacts .filterMany ("whenCreated inRange ? to ?" , startDate , endDate )
311+ .findList ();
312+ }
313+
291314 @ Test
292315 public void testDate_lessThan () {
293316
You can’t perform that action at this time.
0 commit comments