Annotation Type MayBeUninitialized


@Documented @Target({TYPE_USE,METHOD,FIELD}) @Retention(RUNTIME) public @interface MayBeUninitialized
Indicate that a collection or an entity may be intentionally uninitialized.

Operations on an uninitialized collection will always raise a UninitializedCollectionException.

Operations on an uninitialized entity will usually raise a LazyInitializationException if manipulated outside the boundary of a Session.

It is safe to access the Identifiable.getId() of an uninitialized entity and the size of a collection marked with hasSize().

Use this annotation to indicate that a method safely accepts or returns uninitialized entities, we might use this in the future to perform static analysis akin to a nullability checker.

Author:
poirigui
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Indicate that the collection may be uninitialized but always has a size.
  • Element Details

    • hasSize

      boolean hasSize
      Indicate that the collection may be uninitialized but always has a size.

      This means that Collection.size() and Collection.isEmpty() will work as usual.

      Default:
      false