Module jakarta.data

Interface ComparableAttribute<T,V extends Comparable<?>>

Type Parameters:
T - entity class of the static metamodel.
V - type of entity attribute (or wrapper type if primitive).
All Superinterfaces:
Attribute<T>, BasicAttribute<T,V>, ComparableExpression<T,V>, Expression<T,V>, SortableAttribute<T>
All Known Subinterfaces:
BooleanAttribute<T>, NumericAttribute<T,N>, TemporalAttribute<T,V>, TextAttribute<T>
All Known Implementing Classes:
TextAttributeRecord

public interface ComparableAttribute<T,V extends Comparable<?>> extends BasicAttribute<T,V>, SortableAttribute<T>, ComparableExpression<T,V>

Represents a comparable entity attribute in the StaticMetamodel. Comparable entity attributes can be sorted on in query results and can be compared against values in query restrictions.

Where possible, always use the more specific subtypes of ComparableAttribute:

Entity attribute types for which ComparableAttribute is appropriate include:

  • character attributes: char and Character
  • enum attributes - Note that it is provider-specific whether order is based on Enum.ordinal() or Enum.name(). The Jakarta Persistence default of ordinal can be overridden with the jakarta.persistence.Enumerated annotation.
  • UUID attributes

In the above cases, ComparableAttribute, which provides more function, is preferred over SortableAttribute.

Since:
1.1
  • Method Details

    • of

      static <T, V extends Comparable<?>> ComparableAttribute<T,V> of(Class<T> entityClass, String name, Class<V> attributeType)

      Creates a static metamodel ComparableAttribute representing the entity attribute with the specified name.

      Type Parameters:
      T - entity class of the static metamodel.
      V - type of entity attribute (or wrapper type if primitive).
      Parameters:
      entityClass - the entity class.
      name - the name of the entity attribute.
      attributeType - type of the entity attribute.
      Returns:
      instance of ComparableAttribute.