File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes A Design Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "A Design Question" Watch "A Design Question" New topic

A Design Question

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello All,
I am in a process of writing a java program which queries a database. I am retreiving all kinds of information and then I have to display it as a report. My concern is that that I have to make a HashMap inside a HashMap. What I mean is
Keys | Values
Unique| HashMap2
Unique| HashMap3
The HashMap2 also have there unique keys and values.
Is there a better solution than the soln I presented??
Thanks in advance for your help!
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Unless you need to be able to access the key Set or value Collection for the maps, this is equivalent to a single Map keyed by the composite of the two keys in your example (i.e. the composite of Hashmap1Key and Hashmap2Key, etc). One way to create composite keys isAlternatively, if your keys are Strings you might come up with a unique way to concatenate them, etc.
- Peter
Zakaria Haque
Ranch Hand

Joined: Jan 02, 2002
Posts: 60
It pretty much depends on how much time you can put on this project and what the future needs are.
You can use javabeans to represent a record in your database. It can give you type safety. It will take less memory than using a hashtable for each record, it can be crucial if you are retrieving a lot of data.
Rather than having a hastable represent the results from a table, you can use a broker. The immidiate benefit is, you can use lazy data retrieval, which can be important for large amount of data.
Another good thing about using this type of design is, you are open to use other features in future, like client side caching and bluh bluh bluh. But of course, this is not as important if no one will ever need to enhance this program ever.

tobe bondhu nouka bherao<br />shonabo gaan aj shara raat
I agree. Here's the link:
subject: A Design Question
It's not a secret anymore!