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 3841702
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:41:22+00:00 2026-05-19T15:41:22+00:00

In a Spring, JPA, Hibernate project I’m trying to get exception handling working. For

  • 0

In a Spring, JPA, Hibernate project I’m trying to get exception handling working. For the following code:

    @Repository("mscoutService")
    public class MScoutServiceImpl implements MScoutService, Serializable {

        @PersistenceContext
        private EntityManager em;

...
        @Override
        @Transactional
        public void deleteMission(Long missionId) {
            try {
                Mission mis = em.find(Mission.class, missionId);
                em.remove(mis);
            } catch (Exception e) {
                handle_exception();
            }
        }

I’m trying to catch underlying hibernate/jdbc/db exceptions (for example when dependent entities are still present the remove will fail with a org.springframework.orm.hibernate3.HibernateJdbcException) and perform some actions. However the catch code is never reached (checked in the debugger).

I guess this has to do with the way Spring manages this, but I don’t know just how I can catch exceptions during em.remove()…

Any help is appreciated!

  • 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-05-19T15:41:22+00:00Added an answer on May 19, 2026 at 3:41 pm

    This is because the exception occurs when the session gets flushed. And perhaps it gets flushed when the transaction is committed – i.e. by the spring proxy. If you want to manually flush, you can use entityManager.flush().

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

Sidebar

Related Questions

A project I am working on uses Spring 2.5 & JPA with Hibernate as
I´m using JPA Hibernate and Spring MVC. I haved implemented repository pattern. I get
I'm trying to setup Spring using Hibernate and JPA, but when trying to persist
I'm using Hibernate JPA and Spring in my project. Suppose if I try to
I'm working on a Flex/BlazeDS/Spring/JPA/Hibernate web application hooked up to a Microsoft SQL Server
My project uses Spring, JPA, and Hibernate, so that all EntityManager's are injected by
My first project with Hibernate/JPA and Play!, I've got a menu that once working,
HibernateJpaVendorAdapter is used to integrate Spring JPA with Hibernate. For example, the following configuration
I'm trying to set up the following tables using JPA/Hibernate: User: userid - PK
I am trying to use Envers on a project that also uses Hibernate and

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.