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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:32:04+00:00 2026-06-12T01:32:04+00:00

I am doing exception check while saving data in the following way: try {

  • 0

I am doing exception check while saving data in the following way:

    try {
        session.beginTransaction();
        session.update(person);
        session.getTransaction().commit();
    }
    catch(Exception e) {
        session.getTransaction().rollback();
        log.error("Error saving person to database", e);
    }

nevertheless I have my application terminated with an exception somewhere later.

(I did this check in order to avoid of Data truncation errors. May be there is a way to check data truncation without causing an exception in Hibernate?)

  • 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-12T01:32:05+00:00Added an answer on June 12, 2026 at 1:32 am

    When a Hibernate exception is thrown, you cannot use the session, which caused the exception, any more. A rollback is done automatically.

    If you want to continue after the exception, you have two possibilities:

    1. Throw away the old session and create a new one.

    2. Use a StatelessSession instead of a session. A StatelessSession can be used after an exception. In a StatelessSession you have to do the rollback manually.

    Normally you’ll do solution 1.

    Solution 2. is useful if you intentionally provoke an exception and you have a special way to react on it. (For example an index violation exception in an insert operation, and after the exception you do an update instead of an insert.)

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

Sidebar

Related Questions

Is there a way of doing a find_by_x that raises an exception if the
I keep getting System.OutOfMemory exception in my WinForms App which is thrown while doing
What am I doing wrong that an exception is thrown instead of showing a
I know Exception Handling is a very important thing and we are doing it
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
SAX keeps on dying on the following exception: Invalid byte 2 of 3-byte UTF-8
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing my first SL4 MVVM RIA based application and i ran into the following
I am trying to update a progress bar in my main form while a
exit method not working while pressing q return with exception handle error.its a console

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.