In my company we have tables, beans for those tables, and SQL requests using those beans as output and those table as input (iBatis, myBatis, ..).
As usual, I create an entity bean for each table I use in an application.
But where a SQL request is using 7 tables, for example, I need to create a composition of 7 beans. And if another request is using 4 different table, I have to create another composition of 4 beans.
Now I'm wondering if I need to have as many compositions as multiple table tuples in requests the application has.
I thought about beans as interface to solve this problem but it doesn't seem to be possible.
Example of the problem :
Tables CUSTOMER, CAR, CUSTOMERCAR, RETAILER, CUSTOMERRETAILER, ...
SELECT customer.name, retailer.name, car.name WHERE ...
To handle this request output for those entities :
public CustomerRetailerCar {
private Customer customer;
private Car car;
private Retailer retailer;
}
So I end up with a lot of compositions and I'm feeling I'm not solving this problem the right way. Am I wrong?
Any advice appreciated.
Aucun commentaire:
Enregistrer un commentaire