Discussions

EJB design: Generic Pluggable DAO Pattern Implementation

  1. Generic Pluggable DAO Pattern Implementation (1 messages)

    I am implementing a layered architecture application and I access various data sources depending on operation ranging from web services, rdbms, active directories and xml data bases and sometimes I access 2 different data sources in the same operation(method call). I want to implement DAOs based on a common DAO interface so I can acheive loose coupling between the DAO and the business layer. The concern that I have is that not all DAOs will implement all the functionality defined in the interface, so I will end up with some DAOs with empty implimentations. How do you guys tackle this challenge?


    Thanks,
    Shepard
  2. Hi!

    My recommendation is to use the UnsupportedOperationException from the java.lang package. It is better to get a runtime exception and notice the problem (even in production), than just fall through an empty implementation.

    I you have empty implementations when an operation is not supported, you will end up in a code where strange things will happen and it will be really hard to debug. Don't to that!

    /Tomas