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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:21:05+00:00 2026-06-10T13:21:05+00:00

I’m developing a Java project with Visual Paradigm which I am required to use.

  • 0

I’m developing a Java project with Visual Paradigm which I am required to use. Visual Paradigm is using Hibernate. My project was running fine until I’ve added Genady RMI. I’m also required to use RMI.

In the server side I’ve got MainDb which manages all the querys to the database and in the client side I’ve got UserWindow and AdminWindow classes which implements RMI Remote. Theses two classes get the object MainDb through RMI.

When I’m running the server and the client, I’ve got an exception related to Lazy initialization with the error “no session or session was closed”:

failed to lazily initialize a collection of role: dcl.UsuarioRegistrado.ORM_TieneVideosFavoritos, no session or session was closed.

As far as I know, Hibernate is using a different session from which the dcl.UsuarioRegistrado object was created. The problem is that I’m not managing sessions because the class PersistentManager only provides getSession(). The class PersistentManager is the class provided by VisualParadigm to manage Hibernate.

I’ve tried configuring all the entitiies to lazy=”false” but the result has been worse because properties from some entities were not loaded correctly. For instance an object “Topic” was loaded with the String property “TopicName” to null.

So, what could I do to maintain the same session?

Thanks in advance and I’m very sorry but my poor English. It’s difficult for me to explain the situation in English so, again, thanks.

  • 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-10T13:21:06+00:00Added an answer on June 10, 2026 at 1:21 pm

    This is a common problem. When you have a collection in an entity, Hibernate will inject a "Hibernate-aware" collection in the instance. So instead of a List, you get something which remembers the current session ("current" = the session in which the entity was loaded).

    The reason for this is that session == database transaction. If Hibernate would load related entities using a new session, then you could see new rows, updated rows or you could get errors because rows have been deleted which still existed when you loaded the parent entity. It would be a mess.

    To make sure this doesn’t happen, Hibernate will use the original session to load all related entities. But code usually works differently. In one part, you load the entity. Session is closed. Then, in a completely unrelated part, you try to load children -> error.

    There are three solutions:

    1. Disable lazy loading. This often doesn’t work (loads too much, too slow). But it shouldn’t cause errors; there might be a bug lurking in your code.

    2. When you load the entity, get the first entity from each collection. That will properly initialize the collection. The advantage here is that you can decide in your code when to load related instances and when to use rely on Hibernate for lazy loading.

      You can also only load those relations which you need; so this often solve the issues in the previous point. The drawback is that you need to know how other code will use your entity in advance. This is often hard or even impossible.

    3. You can create a new session and "attach" existing objects to this new session using Session.refresh(). Note that you need to be careful here; if you mix refreshed and old objects, you will get errors.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... 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.