Class PurchaseOrder

  • All Implemented Interfaces:
    java.io.Serializable

    @Entity
    public class PurchaseOrder
    extends java.lang.Object
    implements java.io.Serializable
    A persistent entity to demonstrate Master in a Master-Details or Composite pattern for persistent domain model.
    The Purchase Order - Line Items relationship typically demonstrates a Master-Details pattern. In JPA 2.0, following new features are added to support this common pattern used in domain modeling, and this example demonstrates them.
  • Compound, Derived identity: This feature allows the Details type to compose its identity from the the Master's identity.
  • Orphan Delete or Dependent relation: This feature allows to impose composite relation semantics to normally associative relation semantics implied in Java. Composite relation in persistence terms also translates to deletion of Details record from database when the details lose their relation to master.
    Besides the above two key features, this persistent type also shows usage of
  • Auto-generated identity.
  • Enum type persistent attribute.
  • Date type persistent attribute.
  • One-to-One uni-directional, immutable mapping to Customer.
  • One-to-Many bi-directional, immutable mapping to LineItem.
Author:
Pinaki Poddar
See Also:
Serialized Form