-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3473 from ebean-orm/feature/3455-query-beans-impr…
…ovement #3455 - Improve query beans such that filterMany() expressions are only on ToMany relationships
- Loading branch information
Showing
7 changed files
with
176 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ebean-version: 143 | ||
ebean-version: 145 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
ebean-querybean/src/main/java/io/ebean/typequery/TQAssocMany.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package io.ebean.typequery; | ||
|
||
import io.ebean.ExpressionList; | ||
|
||
/** | ||
* Expressions for Query Bean ToMany relationships. | ||
* | ||
* @param <T> The entity bean type | ||
* @param <R> The root query bean type | ||
*/ | ||
public interface TQAssocMany<T, R, QB> { | ||
|
||
/** | ||
* Filter the beans fetched for this relationship. | ||
* | ||
* @param filter The filter to apply | ||
*/ | ||
R filterMany(java.util.function.Consumer<QB> filter); | ||
|
||
/** | ||
* Filter the beans fetched for this relationship. | ||
*/ | ||
R filterMany(ExpressionList<T> filter); | ||
|
||
/** | ||
* @param expressions The expressions including and, or, not etc with ? and ?1 bind params. | ||
* @param params The bind parameter values | ||
* @deprecated for removal - migrate to {@link #filterManyRaw(String, Object...)}. | ||
* <p> | ||
* Apply a filter when fetching these beans. | ||
* <p> | ||
* The expressions can use any valid Ebean expression and contain | ||
* placeholders for bind values using <code>?</code> or <code>?1</code> style. | ||
* </p> | ||
* | ||
* <pre>{@code | ||
* | ||
* new QCustomer() | ||
* .name.startsWith("Postgres") | ||
* .contacts.filterMany("firstName istartsWith ?", "Rob") | ||
* .findList(); | ||
* | ||
* }</pre> | ||
* | ||
* <pre>{@code | ||
* | ||
* new QCustomer() | ||
* .name.startsWith("Postgres") | ||
* .contacts.filterMany("whenCreated inRange ? to ?", startDate, endDate) | ||
* .findList(); | ||
* | ||
* }</pre> | ||
*/ | ||
@Deprecated(forRemoval = true) | ||
R filterMany(String expressions, Object... params); | ||
|
||
/** | ||
* Add filter expressions for the many path. The expressions can include SQL functions if | ||
* desired and the property names are translated to column names. | ||
* <p> | ||
* The expressions can contain placeholders for bind values using <code>?</code> or <code>?1</code> style. | ||
* | ||
* <pre>{@code | ||
* | ||
* new QCustomer() | ||
* .name.startsWith("Shrek") | ||
* .contacts.filterManyRaw("status = ? and firstName like ?", Contact.Status.NEW, "Rob%") | ||
* .findList(); | ||
* | ||
* }</pre> | ||
* | ||
* @param rawExpressions The raw expressions which can include ? and ?1 style bind parameter placeholders | ||
* @param params The parameter values to bind | ||
*/ | ||
R filterManyRaw(String rawExpressions, Object... params); | ||
|
||
/** | ||
* Is empty for a collection property. | ||
* <p> | ||
* This effectively adds a not exists sub-query on the collection property. | ||
* <p> | ||
* This expression only works on OneToMany and ManyToMany properties. | ||
*/ | ||
R isEmpty(); | ||
|
||
/** | ||
* Is not empty for a collection property. | ||
* <p> | ||
* This effectively adds an exists sub-query on the collection property. | ||
* <p> | ||
* This expression only works on OneToMany and ManyToMany properties. | ||
*/ | ||
R isNotEmpty(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.