In my project the persistance layer is implemented in such a way that one DAO per service. For example GenerateCSVDao for csv generation service and so. This DAO may access more than one table and may handle more than one entity.
Now i was asked to refactor the dao layer to make use of Generics. When I gone though the hibernate site for DAO patterns using Generics, DAO's declaration is like CustomerHibernateDao<Customer, custId>.
My doubt is Generic DAO pattern applicable only when one DAO per entitiy cases?
Can't i make use of Generics in my project? if so how?
DAOs can be, but don't have to be, one per entity.
The person who asked you to use generics might have meant on a method level rather than a class level. For example, DAOs frequently query for a list of something. You could return List<Customer> rather than List.
In many cases each entity needs its own DAO. However, when possible have your DAO objects deal with components of objects. For example, you want a DAO for an Invoice class but you probably don't want a DAO for the related LineItem class. Deal with the LineItem objects only as part of Invoice obect itself, ie save the LineItems objects by saving the Invoice object. If you have a DAO for every entity you are probably dealing with an Anemic Domain Model.