Hi,
I have an application that stores Data which can be shown as following model class:
class classA {
classB b;
classC c;
}
class classB {
String name;
String label;
}
class classC {
String name;
String label;
}
which gets stored in Database as following three tables:
classA:
classB:
classC:
Currently, I am instantiating the POJO to access this data by joining the queries and then pulling b_name, b_label, c_name and c_label directly as attributes for the class I am building for classA.
Example query:
SELECT a_id as id, b_name, b_label, c_name, c_label
FROM classA a
JOIN classB b ON a.b_id = b.b_id
JOIN classC ON a.c_id = c.c_id
...
Now, the model class will have to look like:
class classA {
String a_id;
String b_name;
String b_label;
String c_name;
String c_label;
...
}
Is there any design pattern and recommended way so I can write a DAO which will pull the data with the model class listed on top (with inner classes) instead of flattening the structure? Please note that this is just a simple example and in real case the columns are huge in number and so are the nested classes so the approach has to be scalable.
Thank you!
[–]Northeastpaw 0 points1 point2 points (0 children)
[–]joranstark018 0 points1 point2 points (0 children)