I like the whole lifecycle of annotations:
@PrePersist
@PostPersist
@PreRemove
@PostRemove
@PreUpdate
@PostUpdate
@PostLoad
But I think they are complements to Interceptors. Sometimes it easier
to just add an interceptor that gets executed for any CRUD for all
entities.
In your case with the last modified date for example. You could easily
use the reflection api to inspect the bean for any field modifyDate
and set that automatically instead of coding that method on all beans.
So I think there is room for both.
By adding multiple interceptors, like filters in web programming, you
could also move validator executions and other pre executions here.
But as I say, I like them both.
Jira request?
Cheers,
Fredrik
On May 30, 9:43 am, Marc de Verdelhan <marc.deverdel...@yahoo.com>
wrote:
> I started a thread a few weeks ago (
https://groups.google.com/d/topic/neo4j/G5IGZybpqWE/discussion) for a
> problem of that kind.
> Didn't have more time to study the question but I liked the @PrePersist
> solution.
> Cheers,
> Marc
> On Wed, May 30, 2012 at 9:31 AM, Fredrik Hultin
> <fredrik.hul...@collabra.se>wrote:
> > I am using SDN with aspectj. My beans are being backed by the
> > NodeBacked interface (Neo4jNodeBacking class). This gives me the
> > possibility to use the object.persist() method that comes with the
> > interface. I could also use the getTemplate().save(object) method or
> > simply use the template mapped by spring to save the object (I think
> > it is all executing the same code in the end).
> > I would like to execute some code prior to all CRUD`S. In hibernate
> > you can register an interceptor to do that. Is there anything similar
> > in Neo4j?
> > Regards,
> > Fredrik