Index: C:/mifos/workspace2/mifos/test/org/mifos/application/productdefinition/business/LoanOfferingBOTest.java
===================================================================
--- C:/mifos/workspace2/mifos/test/org/mifos/application/productdefinition/business/LoanOfferingBOTest.java	(revision 12183)
+++ C:/mifos/workspace2/mifos/test/org/mifos/application/productdefinition/business/LoanOfferingBOTest.java	(working copy)
@@ -80,6 +80,8 @@
 import org.mifos.framework.hibernate.helper.HibernateUtil;
 import org.mifos.framework.util.helpers.Money;
 import org.mifos.framework.util.helpers.TestObjectFactory;
+
+import sun.security.action.GetLongAction;
 import static org.mifos.framework.util.helpers.TestObjectFactory.EVERY_MONTH;
 import static org.mifos.framework.util.helpers.TestObjectFactory.EVERY_WEEK;
 
@@ -1201,6 +1203,77 @@
 		assertEquals(1, product.getLoanOfferingFunds().size());
 	}
 
+    public void testUpdateWithDuplicateFeeXXX() throws SystemException,
+	    ApplicationException {
+	
+		// test setup: save a loan with one fee associated.  
+		// 
+	    createIntitalObjects();
+	    Date startDate = offSetCurrentDate(0);
+	    LoanOfferingBO product = new LoanOfferingBO(TestObjectFactory
+	                    .getContext(), "Loan Offering", "LOAN", productCategory,
+	                    prdApplicableMaster, startDate, interestTypes,
+	                    new Money("1000"), new Money("3000"), 12.0, 2.0, 3.0,
+	                    (short) 20, (short) 1, (short) 12, false, true, false,
+	                    frequency, principalglCodeEntity, intglCodeEntity);
+	
+	    FeeBO fee = TestObjectFactory.createOneTimeAmountFee("Loan One time ",
+	                            FeeCategory.LOAN, "100", FeePayment.UPFRONT);
+	
+	    LoanOfferingFeesEntity loanOfferingFees1 =
+	            new LoanOfferingFeesEntity(product, fee);
+	    product.addPrdOfferingFee(loanOfferingFees1);
+	
+	    
+	    product.save();
+		HibernateUtil.commitTransaction();
+		HibernateUtil.closeSession();
+		
+		// test setup done
+		
+		// test body: load the same loan obejct from two different hibernate session
+		
+		LoanOfferingBO productLoad1 =
+			(LoanOfferingBO) TestObjectFactory.getObject(
+				LoanOfferingBO.class, product.getPrdOfferingId());
+		// try to get the one-and-only-one loanOfferingFee
+		LoanOfferingFeesEntity loanOfferingFeeLoad1 = null;
+		for (LoanOfferingFeesEntity lofe : productLoad1.getLoanOfferingFees()) {
+			loanOfferingFeeLoad1 = lofe; // should run only once.
+		}
+		HibernateUtil.commitTransaction(); // nothing to be commited but just to be safe
+		HibernateUtil.closeSession();
+	    
+		
+		LoanOfferingBO productLoad2 =
+			(LoanOfferingBO) TestObjectFactory.getObject(
+				LoanOfferingBO.class, product.getPrdOfferingId());
+		// try to get the one-and-only-one loanOfferingFee
+		LoanOfferingFeesEntity loanOfferingFeeLoad2 = null;
+		for (LoanOfferingFeesEntity lofe : productLoad2.getLoanOfferingFees()) {
+			loanOfferingFeeLoad2 = lofe; // should run only once.
+		}
+		HibernateUtil.commitTransaction(); // nothing to be commited but just to be safe
+		HibernateUtil.closeSession();
+	    
+		// expectation: the two LoanOfferingFeesEntity objects 
+		// 1. should be the same (as of equals), 
+		// 2. should have the same hashCode
+		// 2a. operation using hash-based set should work normally.
+		
+		assertEquals("The two loanOfferingFeesEntity objects should have the same identity", loanOfferingFeeLoad1, loanOfferingFeeLoad2);		
+	
+		assertEquals("Since the two are equal, their hashCode should be equal per contract", loanOfferingFeeLoad1.hashCode(), loanOfferingFeeLoad2.hashCode());
+		
+		final int numLoanOfferingsFeeBefore = productLoad2.getLoanOfferingFees().size();
+		productLoad2.addPrdOfferingFee(loanOfferingFeeLoad1);		
+		final int numLoanOfferingsFeeAfter = productLoad2.getLoanOfferingFees().size();
+		assertEquals("Since the two are equal, adding one to one to the other's parent (effectively adding to a set) should be a no-op, ie, not changing the size",
+				numLoanOfferingsFeeBefore, numLoanOfferingsFeeAfter);
+	
+	}
+
+    
 	public void testUpdateLoanOffering() throws ProductDefinitionException,
 			FeeException {
 		createIntitalObjects();
