Package dev.morphia.annotations
Annotation Type PrePersist
-
@Documented @Inherited @Retention(RUNTIME) @Target(METHOD) public @interface PrePersist
Called before the data has been persisted to the datastore (before mapping is done). Here you can alter your class members prior to being saved.Methods with this annotation may optionally take a parameter of type
Datastore. This is the Datastore that data will be persisted to.Example declarations (in order of most to least typical):
@PrePersistvoid cleanUpBeforeSaving() { // perform variable sanitization here as needed }@PrePersistvoid retrieveOtherInfoBeforeSaving(Datastore datastore) { // query datastore as needed }- Author:
- Scott Hernandez
- See Also:
PreLoad,PostLoad,PostPersist