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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:19:15+00:00 2026-06-02T16:19:15+00:00

I ll explain my problem with an example. In my JSP login page ,

  • 0

I ll explain my problem with an example. In my JSP login page , each correct login puts an instance of an Object called ‘User’ which keeps data of the user logging into the HttpSession(session.setAttribute("user",userObject)).How that object is created is, that user’s username and password are checked and an instance(‘User’) of User object is retrieved from HibernateSession.
In another page, when I retrieve above set userObject from HttpSession, the object can be retrieved without error. But when its methods are called, it gives an exception org.hibernate.LazyInitializationException: could not initialize proxy - no Session .Why I cannot that userObject from HttpSession even though I have put it earlier?

Why an empty object(instance variable have no values) exists in HttpSession even though the object had values earlier when it add to the session?

  • 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-02T16:19:16+00:00Added an answer on June 2, 2026 at 4:19 pm

    That can happen if the User entity has a collection property which is lazily fetched. The collection will then only be actually filled with the data from the DB when the caller actually needs to access it by e.g. size(), iterator(), etc. This needs to happen within the very same Hibernate session as when the User is been retrieved. In a properly designed webapplication the Hibernate session has namely a lifespan of exactly one HTTP request-response. So if accessing the collection property happens in a different Hibernate session (read: a different HTTP request), then you will get exaclty this exception.

    To fix this, you either need to fetch the collection property eagerly, or to use Hibernate#initialize() on the collection property while retrieving the User.

    See also:

    • Hibernate reference documentation – Initializing collections and proxies
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will explain the problem with an example. I have a Vehicle object which
So I have an example question as follows: Explain how a JSP page is
It's little hard to explain problem, so better to show example. Test page Code
Ok.. So probably an example is a good way to explain this problem So
to explain my problem, I'll give a simple example: My database has three tables:
maybe I will not correct explain a problem, maybe somebody help me explain this
I think it's easier to explain my problem with an example. I have one
I think that it's easier to explain my problem with an example: Based on
Lemme explain my problem by giving an example: #include <iostream> class PC { public:
To explain my problem, an example is better. I have an ASP.NET MVC 3

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.