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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:34:16+00:00 2026-06-08T13:34:16+00:00

I have a pretty complex domain entities. I want to have lazy loading for

  • 0

I have a pretty complex domain entities. I want to have lazy loading for all of associations. So the scenario is like this:

1.get an instance of my business logic.

2.get an object o from business.

3.ask o to give me other associated objects.

4.prepare the view.

To get rid of hibernate exceptions about closed session when lazy load other objects, I’ve come up to the idea to open and close entire session in controller. Is it a good idea? Are there any better solutions?

Thank you

  • 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-08T13:34:17+00:00Added an answer on June 8, 2026 at 1:34 pm

    Session in view is a bad practice.

    Here is a suggestion for layers which are typically used to work around this problem:

    Controller

    • The controller is only concerned with handling web requests, interpreting them into objects that your services will deal with, and returning services results as web responses. I usually have only one transactional service method call in each controller method, preferring to keep all data access for one controller operation within a single transaction.

    Service

    • The service layer is only concerned with accepting data from controller, obtaining the data it needs (from data layer) to perform its operations, and returning meaningful results. The service should fully load all lazy-loaded entities required by the controller. The service methods here are transactional and won’t have lazy loading issues, and you can assemble results from multiple DAO’s. That way DAO’s don’t need to know about each other.

    Data Access

    • The data access layer is only concerned with persistence (CRUD), allowing access to data with filtering, ordering, and so on.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty complex database schema and would like to know if there
I have a web service method, this calls functionality that's pretty complex in a
I have a pretty complex dom-tree with various exceptions etc. So I don't want
This is a pretty complex MySQL query for me. what i have is a
I have a pretty complex object and I need to get uniqueness of these
I have a set of pretty complex forms that I'd like to implement in
So not sure if this is possible but I have a pretty complex form.
I have a pretty complex object graph G with an object o1 in G
I have a pretty complex linq statement I need to access for different methods.
I have a pretty complex criteria, which I use to retrieve, sort and page

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.