Annotation Type Formula2
Unlike Formula which requires physical SQL with explicit table aliases and
JOIN clauses, @Formula2 accepts a logical expression using dot-notation
property paths. Ebean automatically resolves the required JOIN clauses and
translates the paths to the appropriate table aliases at query time.
// Ebean automatically joins to the 'parent' association
@Formula2("coalesce(familyName, parent.familyName)")
private String effectiveFamilyName;
// Multi-level path: Ebean joins parent and parent.parent
@Formula2("coalesce(familyName, parent.familyName, parent.parent.familyName)")
private String deepEffectiveFamilyName;
The expression supports any SQL function whose arguments are logical property paths. The required JOIN clauses are added automatically when this property is included in a query.
Any property based on a formula becomes a read only property.
By default this formula property is included in queries (just like a normal
mapped property, and consistent with Formula). Note that because a path based
formula automatically adds the JOIN clauses it needs, every query that includes the
property by default also pays the cost of those joins.
Combine @Formula2 with the @Transient annotation to make the property
opt-in. The effect of @Transient is that the formula is NOT included in
queries by default - it must be explicitly included via Query.select() or
Query.fetch(). This is useful when the formula (or the joins it requires) is
relatively expensive and you only want it included when explicitly requested.
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional Elements
-
Element Details
-
value
String valueThe logical expression using property paths.For example:
"coalesce(familyName, parent.familyName)" -
platforms
-