Relational (Java SE 23 & JDK 23)
Description: declaration: module: jdk.jfr, package: jdk.jfr, annotation type: Relational
Keywords: jdk.jfr.Relational class

# Annotation Interface Relational

@Retention(RUNTIME) @Target(ANNOTATION_TYPE) public @interface Relational
Meta annotation for relational annotations, to be used on an annotation.

The following example shows how a relational annotation can be created and used. The `Orderid` annotation indicates there is a relation between `OrderEvent` and `OrderLineEvent`. if they have the same ID, the order line belongs to the order.

    @MetadataDefinition
    @Relational
    @Name("com.example.OrderId")
    @Label("Order ID")
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.FIELD)
    public @interface OrderId {
    }

    @Name("com.example.Order")
    @Label("Order")
    @Category("Orders")
    class OrderEvent extends Event {
        @Label("Order ID")
        @OrderId
        long orderId;

        @Label("Order Date")
        @Timestamp
        long orderDate;
    }

    @Name("com.example.OrderLine")
    @Label("Order Line")
    @Category("Orders")
    class OrderLineEvent extends Event {
        @Label("Order ID")
        @OrderId
        long orderId;

        @Label("Quantity")
        long quantity;

        @Label("Product")
        String product;
    }

Since:
  9