• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Empty interfaces in Hibernate DAO pattern using Generics

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your approach seems appropriate to me in the sense of easy maintenance and readability.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...but my colleagues want to remove the empty interfaces saying that it is unnecessary.



Ugh. tell your colleagues if they want to remove empty interfaces then *they* can be responsible for tracking down all the GenericDAO usages when the spec changes and ItemDAO actually needs something beyond CRUD.
 
Narender Reddy Soma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gregg Bolinger wrote:

...but my colleagues want to remove the empty interfaces saying that it is unnecessary.



Ugh. tell your colleagues if they want to remove empty interfaces then *they* can be responsible for tracking down all the GenericDAO usages when the spec changes and ItemDAO actually needs something beyond CRUD.



well said Gregg!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic