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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:00:43+00:00 2026-06-09T04:00:43+00:00

I am using jquery for UI , Struts2 as Action , JPA for Data

  • 0

I am using jquery for UI , Struts2 as Action , JPA for Data Access Layer. The issue I am facing is that I am getting LazyInitializationException when I am trying to retrieve values from the database . I am getting the below stacktrace :

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.singpost.ctf.core.persistence.CtfTxn.ctfTxnAttribs, no session or session was closed

By default the Fetch="LAZY" , the code is working fine when I changed the Fetch type to EAGER, I don’t know what I have to do further. I am stuck in the middle .

  • 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-09T04:00:46+00:00Added an answer on June 9, 2026 at 4:00 am

    if you try to access a lazy fetched attribute from an entity JPA tries to access the database again to fetch the data. your problem is that at this time you’re outside of the transaction. there are many ways to extend your transaction, e.g. using openSessionInViewFilter

    ( Hibernate/Spring: failed to lazily initialize – no session or session was closed )

    what i personally prefer is to create transfer objects, one for every page you want to show, only including necessary data. you only need to map your entities into those transfer objects, e.g. using the dozer mapper, which is really powerful and convenient.
    that way it’s much easier to manage transactions, and secondly you don’t use database entities in your frontend, because you frontend doesn’t need to know anything about your persistence layer.

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

Sidebar

Related Questions

I'm using struts2-jquery grid. gridmodel in my action class is getting updated correctly. But,
I am creating dependent drop downs using Struts2 jquery. The problem is that getLobList()
I've got the following jsp page and I'm using struts2-jquery-plugin-3.1.1 <script type=text/javascript> function openDialog()
Using jQuery timepickr: http://archive.plugins.jquery.com/project/jquery-timepickr Having included these files: jquery-1.7.1.min.js jquery-ui-1.8.21.custom.min.js ui.timepickr.js And getting this
using jquery's .post i send do my php code an object that with var_dump
Using jQuery, how can I get the input element that has the caret's (cursor's)
I'm using JSP & Struts2 for development. When I login, I call an action,
I'm using the Struts2 jQuery plugin 2.1 and render an autocompleter in my JSP.
Using jquery, how can I find the first div that contains an input with
Using jQuery 1.7.1, I'm trying to create an event handler for the change event

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.