Annotation Interface NaturalIdClass


@Target(TYPE) @Retention(RUNTIME) public @interface NaturalIdClass

Models a non-aggregated composite natural-id for the purpose of loading. The non-aggregated form uses multiple @NaturalId as opposed to the aggregated form which uses a single @NaturalId combined with @Embedded. Functions in a similar fashion as @IdClass for non-aggregated composite identifiers.

@Entity
@NaturalIdClass(OrderNaturalId.class)
class Order {
    @Id
	Integer id;
	@NaturalId @ManyToOne
	Customer customer;
	@NaturalId
	Integer orderNumber;
    ...
}

class OrderNaturalId {
	Customer customer;
	Integer orderNumber;
	...
}
Since:
7.3
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The class to use for loading the associated entity by natural-id.
  • Element Details

    • value

      Class<?> value
      The class to use for loading the associated entity by natural-id.