Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:53:04+00:00 2026-06-15T15:53:04+00:00

I have a class implementing Hibernate PostInsertEventListener which is tied to the Hibernate SessionFactory

  • 0

I have a class implementing Hibernate PostInsertEventListener which is tied to the Hibernate SessionFactory via Spring. The interceptor is specified for post-insert event type . This interceptor gets invoked whenever I perform a session.save(entity). However, the execution happens before the transaction is flushed. This is problematic if the database throws an exception.

Question:
Is there a way I can specify to invoke an interceptor after the session.flush() has been called?

I tried doing insertEvent.getSession().flush() within the event listener but that produces a primary key violation exception since the id was not yet set.

I have not yet explored the registerSynchronization way because it seems like I am missing some basic configuration. The transaction manager being used is org.springframework.orm.hibernate3.HibernateTransactionManager and the transactional boundaries are specified by the @Transactional annotation. Hibernate version is 3.6

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:53:05+00:00Added an answer on June 15, 2026 at 3:53 pm

    Current solution:

    Store the Post(Insert|Update|Delete)Event in a Map with Session as the key. Get the event from the map in the FlushEventListener for the Session and process the event.

    The map used is a Guava Cache with an expiration interval set to minutes. This will catch the case where the flush() fails because of a SQLException and the entry for that session needs to be removed from the map.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i Have this problem in implementing JPA and Hibernate in Spring WS. I
I have a class implementing an interface, which has a multi-parameter constructor, and a
I have class implementing Comparator<String> which should sort strings in such manner that strings
I have an interface with several events I have base class implementing the interface
I have a class Image implementing ISerializable : [Serializable] [XmlRoot(ElementName = IMAGE)] [TypeConverter(typeof(ImageTypeConverter))] public
I have an interface and a class implementing the interface like this: public interface
I have a third party assembly with a public abstract class implementing a certain
I have two Java interfaces and one implementing class. (I have used Eclipse to
In Java I have the necessity of implementing a class that extends Thread within
Hi I'm implementing a given design in java. Basically I have an abstract class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.