I'm trying to write an acceptance test to verify that loan transaction
histories are correct. The test is in the trunk as
ClientLoanTransactionHistoryTest.java.
The test is paying a fee (900), principal (181.8) and interest (1.2)
in a single payment of 1173. The transaction history is updated with
the correct events, so the actual history is not a problem. The
ordering however is.
The transaction history does not always look the same. Sometimes it
looks like this: http://pici.se/pictures/dEUEopidZ.png and other times
like this: http://pici.se/pictures/loSbGVlgp.png
So, what determines the transaction order?
Regards,
Johan
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
It appears that when transactions are assembled for a given loan
payment, an AccountPaymentEntity is created and each transaction is
added to the AccountPaymentEntity.accountTrxns member. The accountTrxns
member is of type Set and is assigned a HashSet which is unordered. My
guess is that when it is persisted, the order is not deterministic since
the collection is of type HashSet.
One low impact potential solution to get a fixed ordering would be to
replace the HashSet with a LinkedHashSet which guarantees iteration
ordering.
Ultimately, a list might be a more appropriate data structure here, but
to make that change would require changing the hibernate mapping too so
it has a larger potential ripple effect.
Cheers,
--Van