-->
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: Hibernate Events vs Interceptors
PostPosted: Tue Dec 06, 2016 3:22 pm 
Newbie

Joined: Tue Dec 06, 2016 3:14 pm
Posts: 1
Hi all,

I am fairly new to Hibernate and wanted to use the Hibernate SaveOrUpdateEventListener for one of my use cases but was strongly advised against using it by a senior engineer saying that Events are the same as Hibernate Interceptors and we should avoid using them (since they can cause the transaction to fail if doing some custom processing).

This raised multiple questions for me:

1. What are the main differences between Events and Interceptors, if any ?
2. In the case of events in general and SaveOrUpdateEvents in particular, are they triggered after the transaction (save/update) has completed ?
3. Do events happen async ?
4. Last but not least, where can I read more about events and their workings ? (I saw http://docs.jboss.org/hibernate/orm/3.3 ... vents.html, but didn't find sufficient info there to defend my usage of events)

Any help, pointers would be greatly appreciated.

Thanks.


Top
 Profile  
 
 Post subject: Re: Hibernate Events v/s Interceptors Usage
PostPosted: Wed Dec 07, 2016 4:25 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
Check out the Events and Interceptor chapter on Hibernate 5.2 User Guide. The 3.3 documentation is outdated, and you should be using the latest Hibernate documentation which is much more comprehensive.

To answer your questions:

1. This one is explained in the aforementioned chapter in our new User Guide.
2. No. Events are triggered during flush time. Check out this article for more info.
3. No. Events happen synchronously.
4. The new User Guide, as I already mentioned.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


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.