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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:32:48+00:00 2026-06-04T18:32:48+00:00

I have an Java webapp, that pulls up an employee’s record and stores it

  • 0

I have an Java webapp, that pulls up an employee’s record and stores it in a home made data holder object, called, oddly enough “EmployeeRecordDataHolder”.

I want to make a copy of EmployeeRecordDataHolder at the beginning of an update process, so that I can do a comparison to report on how the data changed.

I ran into some problems with the original and copy sharing references to member data, with the result being that the original data didn’t stay un-updated.

I originally get the data back from the database via a HashMap. If I populated both objects, the original and copy, from the HashMap get(), would the two objects still share the same references to the data, resulting in the situation that changing the data in one object will also change it in the copy?

What if I used the HashMap to populate the original object and then made a copy by calling all of the getters on the orignal in all of the setters on the copy? Example:

copyDataHolderObj.setSomePieceOfData(  originalDataHolderObj.getSomePieceOfData() );

Would this method result in two objects that could be changed independent of each other?

Thanks much in advance

Steve

  • 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-04T18:32:50+00:00Added an answer on June 4, 2026 at 6:32 pm

    Answer to your first question:

    Yes, both will share references to the same object. HashMap stores the references, hence any update done is done on the original object. This page clearly explains that the changes are reflected.

    Answer to your second question:

    You can do it that way. Creating a copy of all objects.

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

Sidebar

Related Questions

I have a Java EE webapp that works perfectly when I run it on
We have a PHP webapp that calls a Java binary to produce a PDF
I am developing a java webapp, using jsp/jquery/ejb/jboss. I have a web-form that enables
Situation is pretty straightforward. I have a Java webapp that I'm converting to be
I have a java webapp on localhost:8086 that sends and receives webservices to localhost:9080.
I have an existing java webapp that uses Hibernate for it's persistence. I've been
I have a Java/Spring MVC/JSP/JSTL webapp. We have a designer that gave us some
I have a Java webapp WAR file that depends on multiple jars in it's
I have Java webapp that I developed locally with m2eclipse + Jetty + eclipse,
We have a Java webapp that talks to an Oracle database. We are keeping

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.