Hello All,
I have developed DAO layer for Hibernate using the
pattern explained in Hibernate book by Christian Bauer and Gavin King. It is here:
Hibernate DAO Pattern
I need some help on below point of empty interfaces for each entity,
"However, even if only CRUD operations are needed for a particular entity,
you should still write an interface for it, even if it is going to be empty. It is important to use a concrete DAO in your controller code, otherwise you will face some refactoring once you have to introduce specific data access operations for this entity."
I used this pattern for my project but my colleagues want to remove the empty interfaces saying that it is unnecessary.
So lets say ItemDAO is empty then they want to directly use ItemDAOHibernate and refer it using GenericDAO reference like this,
GenericDAO<Item, Long> itemDAO = factory.getItemDAO();
Now this also triggers change in my factory interface and implementation.
Is this good? Is there any trap/problem here that cannot be seen?
I do not have much problem with empty interfaces for 2 reasons,
1. If in future I have to add methods I do not need to refactor
2. Also it is natural to get ItemDAO do do Item things then get GenericDAO.
Please Help.
-Regards
Ajay