I use DAO pattern. I wanna get data from 4 tables, which dto will I use ? Create new dto content all attribute I need ? and create new DAO interface, DAO implements class ? Thanks for rely !
If the 4 tables represent 4 INDEPENDENT entities, i believe you should create separate DTOs for each of them. Ex: Tables: CONTINENT ( Name varchar , poupulation Integer); COUNTRY (Name varchar, poulation Integer, Number literacyRate); VILLAGE (Name varchar, population Integer, Number literacyRate);
You would have DTOs as follows:
class ContinentDTO { String name; int population; //This would be a collection of Country DTO Collection countries;
}
class CountryDTO { String name; int population; double literacyRate; //This would be a collection of Village DTO Collection villages;
//this would refer to the continent DTO to which this country belongs ContinentDTO continent;
}
class VillageDTO { String name; int population; double literacyRate;
//this would refer to the country to which this village belongs CountryDTO country; }
That is a good ideal but I wanna get data from 4 tables so that Object return contents attributes exist in 4 tables. Will i create new dto object Example : Have 4 tables : A, B, C, D with attribute A.a, B.b, C.c, D.d "select A.a, B.b, C.c, D.d where ...." which DAO object I can put in ?
Originally posted by jaikiran pai: If the 4 tables represent 4 INDEPENDENT entities, i believe you should
Who told you this? The purpose of a Transfer object is to transfer data between the data access layer and the client requesting the data. The Transfer Object has nothing to do with entities! A Transfer Object can simply be used to represent the data returned by the consolidation of many remote calls into a single call.
I think you should read the Design Pattern definition again ;-)
FireStorm/DAO supports Table DAOs, View DAOs, Stored Procedure DAOs, and Custom SQL DAOs. Custom SQL DAOs can be used to expose pretty much any SQL statement as a DAO object (multi-table joins, bulk updates, etc.)