title: HashMap value (object) incorrectly overridden with incorrect value
body: <p>I am iterating over a hashmap that is made of string keys and has objects as values and I am setting the attributes of the objects. The value of my hashmap is an object which has other objects as attributes. The problem is that once I set the value for the first object with  key "1-1", in the second iteration when I want to set the value for my second key"2-1", the value corresponding to the first entry which was assigned right before ends up overridden with the value of the second entry, in other words, the attribute value of the first entry ends up overridden with the attribute value corresponding to the second entry. More specifically for key "1-1", in the first iteration of my hashmap, when I print methodtraceHashMap2.get("1-1").Method.Owner.getDeveloperGold(), I get the value "T", then as soon as I move to the second key with value "2-1", I end up with a different value when I reprint methodtraceHashMap2.get("1-1").Method.Owner.getDeveloperGold(), namely I end up with "N", while it should be "T" in reality, the "N" I am getting actually coresponds to the value of methodtraceHashMap2.get("2-1").Method.Owner.getDeveloperGold() which was set for the second entry of my hashmap which has the key "2-1"</p>
  
  <pre><code>for(MethodTrace MethodTrace: methodtraceHashMap2.values()) {
  
          String reqClass=MethodTrace.Requirement.ID+"-"+MethodTrace.Method.Owner.ID;  
  
          MethodTrace.Method.Owner.DeveloperGold=classTraceHashMap.get(reqClass).DeveloperGold; 
          System.out.println("yes");
      }
      System.out.println(methodtraceHashMap2.get("1-1").Method.Owner.getDeveloperGold());
  </code></pre>
  
  <p>Here is the snippet that populates the map but the problem arises in the previous snippet when I populate the attribute MethodTrace.Method.Owner.DeveloperGold of the MethodTrace, I do not believe that the problem is linked to the snippet below</p>
  
  <pre><code>ResultSet myresults = st.executeQuery("SELECT traces.* from traces");
  
      while (myresults.next()) {
          MethodTrace MethodTrace = new MethodTrace();
          Method method= new Method(); 
          Requirement requirement= new Requirement(); 
           requirement=RequirementHashMap.get(myresults.getString("requirementid")); 
           method = MethodHashMap.get(myresults.getString("methodid")); 
  
          MethodTrace.setMethod(method);
          MethodTrace.setRequirement(requirement);
  
          //checking whether the method is present in the superclasses
  
  
          MethodTrace.setGold(myresults.getString("goldfinal"));
          String reqMethod=MethodTrace.Requirement.ID+"-"+MethodTrace.Method.ID; 
          String reqClass=MethodTrace.Requirement.ID+"-"+MethodTrace.Method.Owner.ID;             
  MethodTrace.Method.Owner.DeveloperGold=classTraceHashMap.get(reqClass).DeveloperGold; 
  
           System.out.println(reqMethod+"-");
           System.out.println(MethodTrace.Method.Owner.DeveloperGold);
  
           methodtraceHashMap2.putIfAbsent(reqMethod, MethodTrace);
          System.out.println("WE ARW IN THE LOOP "+methodtraceHashMap2.get("1-1"));
          methodtraceHashMap2.putIfAbsent(reqMethod+"_"+System.currentTimeMillis(), MethodTrace);
          System.out.println("WE ARW IN THE LOOP "+methodtraceHashMap2.get("1-1"));
      }
  </code></pre>