-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @PostPersist method not persisting Entity
PostPosted: Sat Dec 17, 2011 6:27 pm 
Newbie

Joined: Sat Dec 17, 2011 6:19 pm
Posts: 2
Hi All,

I currently have a @PostPersist annotation on a method in one of my domain classes:

Code:
   @PostPersist
   public void createNotification() {
      new ActivityAuditorDelegate().createNotification(this);
   }



The ActivityAuditorDelegate class is an @Configurable and I am Autowiring in some the required Service class.

Code:
@Configurable(dependencyCheck = true, autowire = Autowire.BY_TYPE)
public class ActivityAuditorDelegate {
   @Autowired
   private NotificationService notificationService;



The delegate calls a service class method as follows:

Code:
   @Transactional
   public void distributeNotifications(Long accountId, Long activityId) {
      Notification n = new Notification();
      this.createNotification(n);



I have run debug and know that the method is definitely getting executed, but the Notificaiton never gets persisted - is there any additional config I need?

I can provide the log if it would be useful.

Thanks..


Top
 Profile  
 
 Post subject: Re: @PostPersist method not persisting Entity
PostPosted: Fri Dec 23, 2011 2:40 pm 
Newbie

Joined: Sat Dec 17, 2011 6:19 pm
Posts: 2
Anyone have any idea on this one?

can anyone confirm if it is even possible to persist new entities in a pre/postPersist method?


I have noticed in the documentation here the following line:

Quote:
A callback method must not invoke EntityManager or Query methods!




Does this mean it is impossible to persist new entities? I have also been reading up on this bug which seemed to suggest other people have been able to persist new entities in the pre/postPersist methods. This SO post also seems to suggest it is possible?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.