> We are looking for a pattern that would help us with
> the caching of read-only related data.The type of
> relationship is 1toMany.For example, for each G/L
> accounts, I can have many activities and for each
> activities, I can have many location.
>
> Any ideas ?
Sounds like the Composite Pattern (GOF 163) would satify your requirements.
http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/Terminology.html
Thanks for the suggestion. We are using a mecanisms that looks a bit like this. We do have one big problem due to the large number of possibilities (Thousands of G/L accounts) and also the fact that the resultset are specific to each user accessing the application.
Any additional insight or hints would be appreciated.
Thanks,
Daniel
A few possibilities come to mind but without more detail about your requirements, constraints and problems. I cannot be sure, it is generally better to post too much details rather than not enough. Dont make any assumptions that people know your business domain, you are lucky that I know GL = General Ledger, a lot of potential responders would not, but could have run into similar problems in different domains, Event logging for example uses very similar semantics.
Some practical issues to consider, what structure are you using in your composite object to hold it's children? Why did you make that choice ? HashTable/Maps for example is excellent for fast reading/updates, but slow for inserts. If you are reporting on the data this would be a good structure, if you are doing lots of additions/inserts, it would not. If you have lots of contiguous account references an array is good, if the account refs are sparse it is not.
Consider using a Value Object idiom, this uses a very light weight class (more like a struct), apply this to your most prolific objects first.
Do you have lots of duplicate data, i.e. If the GL account ref is duplicated in each transaction, can you promote it to the containing node ? You should be able to.
How have you mapped from RDMS table to OO semantics ? Generally duplicating the ER relationships in OO in not a good idea. The 1:M particularly needs inverting.
A pattern is a guide it is not set in stone it should be adapted to suit your needs.