I've got two tables, and, of course, 2 JavaBeans.
Table A
id name desc
1 John Malcom
2 Steve Jobs
3 Mark The Best
Table B
id thing fk_A_id (many to one)
1 Bag 1
2 Pet 1
3 Ball 2
In java I have this classes:
class A {
private int id;
private String name, desc;
private List<B> bList;
//getters and setters
}
class B {
private int id;
private String thing;
private int fkA;
}
I have to do a DAO which obtain data from these tables. In the view I have to show data like a sql left outer join between A and B tables, which returns a JSON object, something like this
Aid Aname Adesc Bthing
1 John Malcom Bag
1 John Malcom Pet
2 Steve Jobs Ball
3 Mark The Best null
This data will be shown through a boostrap-datatable, and my Controler would populate it as a plain json object.
How do you build the DAO/JavaBeans to solve it? I think the best option is creating an utility class which transform, the List objects in this plain json, which does not alter the basic structure of the model, but a partner has suggested other solution.
Aucun commentaire:
Enregistrer un commentaire