Sankar Sarma

Greenhorn
+ Follow
since Mar 26, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sankar Sarma

Campbell Ritchie wrote:If those objects all implement the same interface, try to declare them of that interface type, then maybe you can avoid the class cast.


Thank you all for the reply (Sorry for the late ack, but I am new and I kept looking at 'My Posts' and it only shows my version )

The objects return a POJO that represents a 'table' with getters and setters for each field - the generic object has a map that holds reference to each field... I'll probably use a 'translator' service to map the mapped objects to actual attributes.
14 years ago
Hello All

I have a design question regarding the above:

I have a generic data class that has a variable list of attributes - each representing a column in a table (name, type etc.). I have a class that reads data from the database and populates instances of the data class (e.g., there is a load(ID, tableName) method that returns an instance of the data for the given table).

I also have a bunch of classes that extend the above class - these represent actual tables and have the actual attributes of each table. these are used as POJOs with getters and setters.


e.g






What I want to be able to do is to "cast" the generic data class as a POJO - e.g. when my Data instance is returned, I'd like to map the data values for each column to the actual instance variables in the subclass.


What would be an ideal design for something like this.

Thanks in advance.
15 years ago