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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:16:53+00:00 2026-06-01T06:16:53+00:00

When I do a Hibernate merge() to a ItemVersionLanguage object, I got ERROR [org.hibernate.LazyInitializationException]

  • 0

When I do a Hibernate merge() to a ItemVersionLanguage object, I got “ERROR [org.hibernate.LazyInitializationException] (pool-9-thread-1) could not initialize proxy – no Session: org.hibernate.LazyInitializationException: could not initialize proxy – no Session” from the codes below.

But when I get data from it, it works fine from either ItemVersion or ItemVersionLanguage’s url.

I don’t have a @Transactional wrapping the code in which merge() locates.

ItemVersionLanguage.java

@Entity
@Table(name = "item_version_language")
public class ItemVersionLanguage implements java.io.Serializable {
   private String url;
   private ItemVersion itemVersion;

   public void setUrl(String url)
   {
      this.url = url;
   } 
   @Column(name = "url")  
   public String getUrl()
   {
      if(this.url == null)
      {
          return this.itemVersion.url; //this results in the problem!
      }
      else
      {
          return this.url;
      }
   }
   public void setItemVersion(ItemVersion itemVersion)
   {
       this.itemVersion = itemVersion;
   }

   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "item_version_obj_id", nullable = false)
   public ItemVersion getItemVersion()
   {
       return this.itemVersion;
   }
}

ItemVersion.java

@Entity
@Table(name = "item_version")
public class ItemVersion implements java.io.Serializable {
   private String url;

   public void setUrl(String url)
   {
      this.url = url;
   }   
   @Column(name = "url")
   public String getUrl()
   {
      return this.url;
   }
}

Am I doing anything wrong?

  • 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-01T06:16:54+00:00Added an answer on June 1, 2026 at 6:16 am

    Lazy initialization enables the variable to act as a proxy which can fetch its value as need be. This error occurs when code attempts to read from the variable after the session that retrieves the entity has been closed, which makes it impossible for the proxy to lazily fetch its value.

    You can use Hibernate.initialize(itemVersionLanguage.getItemVersion()) to load the proxy’s value before the session is closed.

    See http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/performance.html#performance-fetching-initialization for more details.

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

Sidebar

Related Questions

Hibernate has a handful of methods that, one way or another, takes your object
Hibernate connections to MySQL my db are not closing. After clicking 10 times in
Does hibernate provide a method that returns an object's state (transient, persistent, detached)?
I am testing hibernate and giving this query to transaction = session.beginTransaction(); city =
Possible Duplicate: Spring + Hibernate : a different object with the same identifier value
How do you handle object equality for java objects managed by hibernate? In the
Is there a Hibernate 4 version of org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener ? I'm attempting to upgrade my
I am using JPA with Hibernate underneath, and I am having trouble getting merge
I am attempting to persist/merge a brand new object graph through jpa but it
Maybe I misunderstood the semantics of get and merge in hibernate, but if I

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.