I have one question.
Is it my correct understanding if I’m using multithreaded socket server in java would I create the sessionfactory in the server and then pass a new session to each thread created in the server?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
A Hibernate session is not thread-safe, and must not be shared between threads. It’s thus the created thread that should create its own session.
But a session shouldn’t be open for the duration of a thread, either. A session’s lifespan is typically the same as a transaction lifespan: very short.