Defining the DAO interfaces
An interface in the Java programming language defines a set of method signatures and constant declarations. Interfaces expose behaviors (or what can be done) and define a contract that implementing classes promise to provide (how it is done). Our DAO layer will contain one interface and one implementing class per domain object.
Note
The use of interfaces is an often misunderstood pattern in enterprise programming. The argument goes along the line, "Why add another set of Java objects to your codebase when they are not required". Interfaces do add to the number of lines of code that you write, but their beauty will be appreciated as soon as you are asked to refactor an aging project that was written with interfaces from the start. I have migrated an SQL-based persistence layer to a JPA persistence layer. The new DAO implementation replaced the old without any significant change in the service layer, thanks to the use of interfaces. Development was done in parallel...