My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for

This project has moved to github. You can find the new documentation here

LifecycleMethods  
Updated Jul 22, 2013 by j...@antwerkz.com

This project has moved to github. You can find the new documentation here

Comment by dave.tro...@gmail.com, Oct 4, 2010

Lifecycle methods appear to be able to be declared with zero, one, or two arguments:

@<LifeCycleEventAnnotation> DBObject lifecycleMethod(DBObject dbObj, Mapper mapper);

- with/ arguments left off the right as required.

The return value appears to be utilized as follows:

  • PrePersist? - Persisted fields are updated/appended to returned DBObject
  • PreSave? - Value ignored.
  • PreLoad? - Persisted values are restored to the DBObject if not present before mapping to POJO
  • PostLoad? - Value ignored.
Comment by ostraz, Mar 26, 2012

'EntityListerners?' -> EntityListeners?

@link(See the AllAnnotation? for a full list of the annotations supported.) -> http://code.google.com/p/morphia/wiki/AllAnnotations

Comment by svpranay, Apr 9, 2013

The below example is a bit confusing when I first looked at it. As I understand the below code will update the date field only on calling .save on the entity but doesn't update it when you use update operations that does not call .save.

class BankAccount? {

@Id String id; Date lastUpdated = new Date();

@PrePersist? void prePersist() {lastUpdated = new Date();}

}


Sign in to add a comment
Powered by Google Project Hosting