[Neo4j] [SDN] Smart way to update a date on saving?

42 views
Skip to first unread message

Marc de Verdelhan

unread,
Apr 18, 2012, 10:43:12 AM4/18/12
to ne...@googlegroups.com
Hi graphistas,

I'd like to add a lastModified attribute on my nodes/relationships. But I'd prefer to automate the object.lastModified = new Date(); before each persist() or each save(). So is there any elegant way to update a date attribute on saving?

If not, it may be a useful feature to add to SDN. It could take the form of an annotation like this (@UpdateOnSaving):

@NodeEntity
public class Project {

@GraphId
Long id;
@Indexed
String objectId;

@UpdateOnSaving
Date lastModified;
public Project(String objectId) {
this.objectId = objectId;
}
}

I'm waiting for your thought about that.

Cheers,

Marc

Michael Hunger

unread,
Apr 18, 2012, 11:50:53 AM4/18/12
to ne...@googlegroups.com
Not yet, but sounds like a good idea.

Rather a listener that gets the objects passed in ? Otherwise this is very date-specific.

Or a property-handler that you can register for an annotation.

Michael

Craig Giordano

unread,
Apr 18, 2012, 12:57:18 PM4/18/12
to ne...@googlegroups.com
It would be great if there was support for JPA annotations like @PrePersist and @PreUpdate.

Craig
Reply all
Reply to author
Forward
0 new messages