Module jakarta.data
Package jakarta.data.metamodel
package jakarta.data.metamodel
A static metamodel for entities that are used in Jakarta Data repositories.
The StaticMetamodel allows for type-safe
operations that avoid the
need to hard-code entity attribute names as Strings. For example,
@Entity
public class Product {
@Id
public long id;
public String name;
public float price;
public LocalDate producedOn;
}
@StaticMetamodel(Product.class)
public interface _Product {
String ID = "id";
String NAME = "name";
String PRICE = "price";
String PRODUCEDON = "producedOn";
NumericAttribute<Product,Long> id = NumericAttribute.of(
Product.class, ID, long.class);
TextAttribute<Product> name = TextAttribute.of(
Product.class, NAME);
NumericAttribute<Product,Float> price = NumericAttribute.of(
Product.class, PRICE, float.class);
TemporalAttribute<Product,LocalDate> producedOn = TemporalAttribute.of(
Product.class, PRODUCEDON, LocalDate.class);
}
...
@Repository
Products products;
...
Order<Product> order =
Order.by(_Product.price.desc(),
_Product.name.asc(),
_Product.id.asc());
page1 = products.findByNameLike(namePattern, pageRequest);
The module Javadoc provides an overview of Jakarta
Data.
-
ClassDescriptionAttribute<T>Supertype for
StaticMetamodelfields representing entity attributes.BasicAttribute<T,V> Represents an entity attribute in theStaticMetamodelthat is neither sortable nor capable of order-based comparison.Represents a boolean entity attribute in theStaticMetamodel.ComparableAttribute<T,V extends Comparable<?>> Represents a comparable entity attribute in theStaticMetamodel.NavigableAttribute<T,U> Represents an entity attribute that is an embeddable or association to another entity.NumericAttribute<T,N extends Number & Comparable<N>> Represents a numeric entity attribute in theStaticMetamodel.Represents a entity attribute in theStaticMetamodelthat is sortable, but incapable of order-based comparison.Annotates a class which serves as a static metamodel for an entity, enabling type-safe access to entity attribute names and related objects such as instances ofSorts for an attribute.TemporalAttribute<T,V extends Temporal & Comparable<? extends Temporal>> Represents a temporal entity attribute in theStaticMetamodel.Represents an textual entity attribute in theStaticMetamodel.