Top Description Interfaces Annotations
module jakarta.data

Package jakarta.data.metamodel


A static metamodel for entities that are used in Jakarta Data repositories.

The jakarta.data.metamodel.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;
}

@StaticMetamodel(Product.class)
public interface _Product {
    String ID = "id";
    String NAME = "name";
    String PRICE = "price";

    SortableAttribute<Product> id = new SortableAttributeRecord<>(ID);
    TextAttribute<Product> name = new TextAttributeRecord<>(NAME);
    SortableAttribute<Product> price = new SortableAttributeRecord<>(PRICE);
}

...

@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.

Interface Summary

Modifier and TypeInterface and Description
public interface
Attribute<
entity class of the static metamodel.
T
>

Represents an entity attribute in the StaticMetamodel.

public interface
SortableAttribute<
entity class of the static metamodel.
T
>

Represents a sortable entity attribute in the StaticMetamodel.

public interface
TextAttribute<
entity class of the static metamodel.
T
>

Represents an textual entity attribute in the StaticMetamodel.

Annotation Summary

Modifier and TypeAnnotation and Description
public @interface
StaticMetamodel

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 of Sorts for an attribute.