Annotation Type PreLoad

  • @Documented
    public @interface PreLoad
    Called before the data has been loaded into the object. Here you can alter the raw BSON Document from the datastore prior to object initialization.

    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 will be loaded from. You can alter the Document here and those changes will be reflected when the object is loaded. The Datastore parameter (if used) will be the Datastore this Document was loaded from.

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

     private void fixupDocument(Document doc) {
       // doc is the Document we will be initialized from. Document elements can be manually changed or removed.
     private void performAdditionalQueriesBeforeLoading(Document doc, Datastore datastore) {
       // doc is the Document we will be loaded from. datastore is the datastore the Document originated from.
    Scott Hernandez
    See Also:
    PostLoad, PrePersist, PostPersist