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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:00:35+00:00 2026-06-05T05:00:35+00:00

This is a very simple question that applies to programming web interfaces with java.

  • 0

This is a very simple question that applies to programming web interfaces with java. Say, I am not using an ORM (even if I am using one), and let’s say I’ve got this Car (id,name, color, type, blah, blah) entity in my app and I have a CAR table to represent this entity in the database. So, say I have this need to update only a subset of fields on a bunch of cars, I understand that the typical flow would be:

  1. A DAO class (CarDAO) – getCarsForUpdate()
  2. Iterate over all Car objects, update just the color to say green or something.
  3. Another DAO call to updateCars(Cars cars).

Now, isn’t this a little beating around the bush for what would be a simple select and update query? In the first step above, I would be retrieving the entire object data from the database: “select id,name,color,type,blah,blah.. where ..from CAR” instead of “select id,color from CAR where …“. So why should I retrieve those extra fields when post the DAO call I would never use anything other than “color”? The same applies to the last step 3. OR, say I query just for the id and color (select id,color) and create a car object with only id and color populated – that is perfectly ok, isn’t it? The Car object is anemic anyway?

Doesn’t all this (object oriented-ness) seem a little fake?

  • 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-05T05:00:37+00:00Added an answer on June 5, 2026 at 5:00 am

    For one, I would prefer that if the RDBMS can handle your queries, let it. The reason is that you don’t want your JVM do all the work especially when running an enterprise application (and you have many concurrent connections needing the same resource).

    If you particularly want to update an object (e.g. set the car colour to green) in database, I would suggest a SQL like

    UPDATE CAR SET COLOR = 'GREEN';
    

    (Notice I haven’t used the WHERE clause). This updates ALL CAR table and I didn’t need to pull all Car object, call setColor("Green") and do an update.

    In hindsight, what I’m trying to say is that apply engineering knowledge. Your DAO should simply do fast select, update, etc. and let all SQL “work” be handled by RDBMS.

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

Sidebar

Related Questions

This should be very simple question. There are many programming languages out there, compiled
I'm sure this is a very simple question, but embarrassed to say I can't
This is probably a very simple question that I am working through in an
I think this is a very simple question, but I’m new to programming so
This is a very simple question, but after a few hours surfing the web
This is a very simple question, but embarrassingly enough I am not sure how
it is a very simple question that I'm not finding an answer for it.
I'm hoping that this is a VERY simple question, but it's driving me insane!
A very simple question that is actually stated in the title. Let's say i
Hopefully this is a very simple question. I have a makefile pattern rule that

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.