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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:49:10+00:00 2026-05-13T16:49:10+00:00

So in a recent project (a small internal tool), I want to experiment with

  • 0

So in a recent project (a small internal tool), I want to experiment with not using an ORM tool which we typically use in all our projects. The reason is that I particularly aren’t a fan of them specially in complex projects with complex object hierarchies and relationships. Using an ORM it becomes difficult to debug performance issues and other issues arising from a lot of things that the ORM library might do under the covers to “optimize”.

So I was thinking of a way to lazy load certain properties of objects when I don’t have the help of an ORM tool. Suppose an example:

class Student {
private List<Course> courses;

public List<Course> getCourses() {...}
public void setCourses(List<Course> courses) {...}
}

So in this case we put “courses” lazily. So I want a way to differentiate between a scenario in which the “courses” has not been loaded from the database and when “courses” is actually null even after fetching from the DB.

What are the typical ways in which I can achieve it. I was thinking that probably associate a special empty object of type “Course” denoting that actually no data exists in the DB. And the java null would mean that the data is not fetched from the DB. But this would break abstraction a bit in the sense that the getter for such lazy properties need to make the decision to accessing the DAO to getting the data.

  • 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-05-13T16:49:11+00:00Added an answer on May 13, 2026 at 4:49 pm

    If you don’t like standard ORM libraries like Hibernate, why don’t you use a tool like iBATIS? iBATIS is a half-way house between Hibernate and plain SQL. Essentially it maps result sets to Java objects, however it doesn’t write any SQL for you.

    We switched to it from Hibernate after – like you – finding that Hibernate doesn’t work so well for more complex schemas.

    It does support dynamic class enhancement, however it also supports avoiding N+1 selects by putting the join in SQL (sorry, that’s badly explained, but check the user guide for more info).

    Anyway, to answer your actual question, I would probably implement this by using cglib or something similar to enhance a class (create a dynamic subclass). You keep a Map of properties which have been loaded or not, and then you have no need for special values.

    However I think it’s probably a better idea to use a library which already exists, re-inventing the wheel is never a good idea if at all possible.

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

Sidebar

Related Questions

No related questions found

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.