Annotation Type AsEmbedded


  • @Retention(RUNTIME)
    @Target({FIELD,METHOD})
    public @interface AsEmbedded
    Makes that the behavior in the view for a reference (or collection) to entity will be as in the case of a embedded object (or collection to entities with CascadeType.REMOVE).

    Applied to references

    By default in the case of a reference to an embedded object the user can create and edit its data, while in the case of a reference to an entity the user can only to choose an existing entity. If you put @AsEmbedded then the user interface for references to entities behaves as a in the embedded case, allowing to the user to create a new object and editing its data directly. It has no effect in case of a reference to embedded object.
    Warning! If you remove an entity its referenced entities are not removed, even if they are displayed using @AsEmbedded.
    Example:
      @ManyToOne 
      @AsEmbedded
      private Seller seller;
     

    Applied to @OneToMany/@ManyToMany collections

    By default the collections with CascadeType.REMOVE allow the users to create and to edit elements, while the other collections allows only to choose existing entities to add to (or remove from) the collection. If you put @AsEmbedded then the collection behaves always as a collection with CascadeType.REMOVE, allowing to the user to add objects and editing them directly.
    Warning! If you remove an entity from an @AsEmbedded collection (so with no CascadeType.REMOVE), the relationship with the parent is removed but the entity itself still exists, unless you use orphanRemoval=true.
    Note: JPA 1.0 does not support collections of embedded objects, therefore we assume a collection of entities with CascadeType.REMOVE as a collection of embedded objects.
    Example:
      @AsEmbedded
      @OneToMany(mappedBy="seller")
      private Collection customers;
     
    Author:
    Javier Paniza
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String forViews
      List of comma separated view names where this annotation applies.
      java.lang.String notForViews
      List of comma separated view names where this annotation does not apply.
    • Element Detail

      • forViews

        java.lang.String forViews
        List of comma separated view names where this annotation applies.

        Exclusive with notForViews.
        If both forViews and notForViews are omitted then this annotation apply to all views.
        You can use the string "DEFAULT" for referencing to the default view (the view with no name).

        Default:
        ""
      • notForViews

        java.lang.String notForViews
        List of comma separated view names where this annotation does not apply.

        Exclusive with forViews.
        If both forViews and notForViews are omitted then this annotation apply to all views.
        You can use the string "DEFAULT" for referencing to the default view (the view with no name).

        Default:
        ""