- Type Parameters:
T- the root table type (the entity from which the path originates).E- the field type of the designated element.
- All Superinterfaces:
Navigable<T,E>
- All Known Subinterfaces:
Metamodel.Key<T,,E> TypedMetamodel<T,E, V>
- All Known Implementing Classes:
AbstractKeyMetamodel,AbstractMetamodel,Metamodel.KeyDelegate
User_ for a User entity) contain static fields representing each entity field, enabling
compile-time verification of field references.
Nested Paths (Fully Qualified)
Nested paths traverse from the root entity through relationships by chaining field accessors:
// Traverse User → City → Country → name
User_.city.country.name
Nested paths are always unambiguous because they explicitly specify the traversal from the root entity. Storm automatically generates the necessary JOINs based on the path.
Short Form
Short form references a table's metamodel directly without specifying the path:
// Reference Country directly
Country_.name
Short form works only when the table appears exactly once in the entity graph. If the table is referenced in multiple places, Storm cannot determine which occurrence you mean and throws an exception.
Short form is also used to reference tables added via custom joins, since those tables are not reachable through nested paths.
Path Resolution
When resolving a metamodel reference, Storm follows this order:
- Nested path — If a path is specified (e.g.,
User_.city.country), use the alias for that specific traversal - Unique table lookup — If short form (e.g.,
Country_), check if the table appears exactly once in the entity graph or registered joins - Error — If multiple paths exist, throw an exception indicating the ambiguity
- Since:
- 1.2
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceMetamodel.Key<T extends Data,E> Marker interface for metamodel fields that correspond to columns known to be unique.static final recordMetamodel.KeyDelegate<T extends Data,E> Delegating wrapper that adds theMetamodel.Keymarker to an existingMetamodelinstance. -
Method Summary
Modifier and TypeMethodDescription@Nullable ObjectExtracts the value from the given record as specified by this metamodel.booleanisIdentical(T a, T b) Checks whether the value extracted fromais identical to the value extracted fromb.booleanChecks whether the value extracted fromais the same as the value extracted fromb.static <T extends Data,E>
Metamodel.Key<T, E> Returns aKeyview of the given metamodel.Creates a new metamodel for the given root rootTable and path.Creates a new metamodel for the given record type.table()Returns the table that holds the column to which this metamodel is pointing.
-
Method Details
-
root
Creates a new metamodel for the given record type.- Type Parameters:
T- the root table type.- Parameters:
table- the root table to create the metamodel for.- Returns:
- a new metamodel for the given record type.
-
of
Creates a new metamodel for the given root rootTable and path.This method is typically used to manually create a metamodel for a component of a record, which can be useful in cases where the metamodel cannot be generated automatically, for example, local records.
- Type Parameters:
T- the root rootTable type.E- the record component type of the designated component.- Parameters:
rootTable- the root rootTable to create the metamodel for.path- a dot separated path starting from the root table.- Returns:
- a new metamodel for the given root rootTable and path.
- Throws:
PersistenceException- if the metamodel cannot be created for the root rootTable and path.
-
table
Returns the table that holds the column to which this metamodel is pointing. If the metamodel points to an inline record, the table is the parent table of the inline record. If the metamodel is a root metamodel, the root table is returned. -
getValue
Extracts the value from the given record as specified by this metamodel.The returned value may be
nullif this metamodel represents a nullable field or if any parent metamodel in the access path resolves tonull(for example, when navigating through an optional or nullable nested record).Implementations may return a non-null value, but callers must not rely on that unless they statically know they are using a non-null metamodel variant.
- Parameters:
record- the root record from which the value is extracted.- Returns:
- the extracted value, or
nullif the value cannot be resolved. - Since:
- 1.7
-
isIdentical
Checks whether the value extracted fromais identical to the value extracted fromb.Semantics: This method performs an identity comparison on the extracted field value. It returns
trueif and only if both extracted values refer to the same object instance.This operation is only meaningful for reference-typed fields. It is not defined for primitive-typed fields.
Performance guarantees:
- No boxing or unboxing is performed.
- No value coercion or conversion is performed.
- No
equals(...)or comparator logic is used.
- Parameters:
a- the instance from which the left-hand value is extracted, must not benull.b- the instance from which the right-hand value is extracted, must not benull.- Returns:
trueif both extracted values are the same object instance.- Since:
- 1.7
-
isSame
Checks whether the value extracted fromais the same as the value extracted fromb.Semantics: This method performs a value comparison on the extracted field value. The comparison is defined by the field type:
- For primitive-typed fields, values are compared using
==. - For reference-typed fields, values are compared using their defined value semantics
(for example
equals(...)or an equivalent comparator).
Performance guarantees:
- No boxing or unboxing is performed.
- No identity comparison is performed.
- The comparison operates directly on the extracted values.
- Parameters:
a- the instance from which the left-hand value is extracted, must not benull.b- the instance from which the right-hand value is extracted, must not benull.- Returns:
trueif both extracted values are equal by value.- Since:
- 1.7
- For primitive-typed fields, values are compared using
-
key
Returns aKeyview of the given metamodel. Ifmetamodelalready implementsMetamodel.Key, it is returned as-is; otherwise it is wrapped in a delegate that implementsKey.This factory is intended for cases where the generated metamodel does not carry the
Keymarker (for example, composite primary keys or dynamically constructed metamodels), or where a column is known to produce unique values in a particular query context (for example, a column that appears in aGROUP BYclause).Important: callers are responsible for ensuring that the column produces unique values in the context where the key is used. Using a non-unique column as a keyset pagination key will silently skip rows when duplicate values span page boundaries.
The returned key reports
Metamodel.Key.isNullable()from the underlying field: a nullable field stays nullable when viewed as a key, so keyset pagination keeps rejecting it.- Type Parameters:
T- the root table type.E- the field type.- Parameters:
metamodel- the metamodel to view as a key.- Returns:
- a
Keyinstance backed by the given metamodel. - Since:
- 1.9
-