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

  • Home
  • SEARCH
  • 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 8634605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:45:56+00:00 2026-06-12T09:45:56+00:00

I connect to my database with one session. I have always the same session

  • 0

I connect to my database with one session. I have always the same session in my whole program. My Thread “1” catches primary data from the database. The user must be allowed to cancel this thread. So if the user presses the cancel button to often or to fast (this is my interpretation) the following error occures:

ERROR org.hibernate.AssertionFailure - HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) 
org.hibernate.AssertionFailure: possible non-threadsafe access to the session

The same errors occures if i cancel my thread “2” which is running in the background after my thread “1” ist finished and the try to load another primary data set from the database.

Is the failure that i am using the same session in my two threads?

What is the right way to solve such a problem?

  • 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-12T09:45:57+00:00Added an answer on June 12, 2026 at 9:45 am

    Each thread should obtain its own session from Hibernate session factory.

    It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.

    See here: Hibernate Session JavaDoc

    When you “cancel” a thread – it should do its own cleanup like transactions rollback, session close etc.

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

Sidebar

Related Questions

I have one problem regarding retriving data from database. I have created one database
In cakephp I want to be able connect to a different database from one
Some one asked about How to connect to SQL server database from JavaScript? and
I will connect with one database from several machines. In all machines they need
I have once ajax call which does connect to database, sets one flag in
I am retrieving data from database using AJAX and PHP. In database one of
i wrote program to connect oracle database 11g for my android application to store
I have to perform a query similar to: <?php //....connect to database $old =
I am using sessions to pass user information from one page to another. However,
We have a thread program that sends bulk mail. The information like 1. To

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.