Annotation Interface NonPersistent


@Documented @Retention(RUNTIME) @Target(FIELD) public @interface NonPersistent
Annotation to exempt fields from being read from or written to the database. Serialization is not affected.
In earlier versions, the volatile modifier had been misappropriated to achieve this.
Since volatile has other (possibly unintended) semantics, the use of @NonPersistent is strongly recommended, if just the exclusion from database is intended.
Examples:
        @NonPersistent
        private String aString;

        @NonPersistent("needed in log, but not in database")
        private String bString;
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional documentation of the reason why the warning is suppressed
  • Element Details

    • value

      String value
      Optional documentation of the reason why the warning is suppressed
      Default:
      ""