Hi,

My understanding is that spring(at least in 2.5.1) can inject into aspectJ aspects and I am wondering if it is possible to do it on @EntityListeners(JPA) too.

Code:
@Entity
@EntityListeners({OwnerListener.class})
public class foo {
  Owner owner;
}

public class OwnerListner {
  @PrePersist
  public void setOwner(o) {
    o.setOwner(getCurrentUser());
  }
}
Basically, I want all my entities to have an owner field which is the current user and this I believe is the right way(just set the owner before an object is persisted/updated).

However, when it actually run, I got a "deteched object passed to persist" which I think is reasonable too as the getCurrentUser call(actually acegi one) does return a detached object).

At the moment I thought about using asjectJ to watch the OwnerListener.setOwner call then do the actual inject there

Code:
   user = getCurrentUser();
   user = userDao.get(user.getId()); // now I assume is attached ?
   o.setOwner(user);
   pjp.proceed();
and beause spring can inject properties into an aspectJ bean, I should be fine.

It just seems to be one more level of indirection which I hope can be eliminated.

comments/pointers ?