I’ve implemented the Map strategy as suggested by Leo. Thought it’s not a unanimous solution, it is something I can use immediately and I do think it is a pretty good alternative. It not only allows the elimination of excessive setters and getters but you can also create ArrayList’s (or any other collection) to hold each field dynamically. There’s no need to know the instance name of each list because you can access them by the Map’s key (key = column name), therefore avoiding the need to code a list for each field. I truly think this is a major advantage. Then it’s possible to iterate each field straight to a string (or any other type) making the code leaner.
For example:
Class LoadBigFile connects to the database and loads the file’s contents to a map.
Something like this (please note: this is just a very vague example to illustrate what can be done):
Class LoadBigFile{
private HashMap<String, ArrayList<String>> filemap = new HashMap<String,ArrayList<String>>();
////// ...Code to connect to database and load the file contents into the map
////// Setter and getter for the map:
public void setFileMap(HashMap<String, ArrayList<String>> filemap){this.filemap=filemap;}
public HashMap<String, ArrayList<String>> getFileMap(){return this.filemap;}
}
Then in the class you’re going use the data (unpack the map):
LoadBigFile loadBigFile = new LoadBigFile();
String customer = loadBigFile.getFileMap().get("CUSTOMER").get(iterator));
NOTE: I will not go over the iterator because it would be off topic. All I can say is that it works.
Even thought I am still looking into other techniques such as ORM and JPA, I’ll try the map approach as I develop my skills and learn more sophisticated methods.
Thank you all. I hope this question helps other java enthusiasts out there.