Annotation Type PostPersist


  • @Documented
    @Inherited
    @Retention(RUNTIME)
    @Target(METHOD)
    public @interface PostPersist
    Called after the data has been persisted from the java object. Here you can alter the BSON Document before it is saved.

    Methods with this annotation may optionally take a parameter of type Document and/or a parameter of type Datastore. If both parameters are used, the order is unimportant. For typical usage, the method should take a Document parameter.

    The Document parameter (if used) will be the document that this object was saved to. You can alter the Document to change how it will be saved. The Datastore parameter (if used) will be the Datastore this Document will be saved to.

    Example declarations (in order of most to least typical):

     @PostPersist
     private void removeUnneededDataFromDoc(Document doc) {
       // doc is the Document this object was written to. It can be altered here prior to saving.
     }
     
     @PostPersist
     private void performAdditionalQueriesBeforeSaving(Document doc, Datastore datastore) {
       // doc is the Document this object was written to. datastore is where it will be saved in.
       // doc can be altered here prior to saving.
     }
     
    Author:
    Scott Hernandez
    See Also:
    PreLoad, PostLoad, PrePersist