Persistence plays an important role in most programs. The creation of unit tests for persistence mechanisms is often accompanied by major problems, because both the execution speed and the large number of dependencies make the naive testing approach difficult.
Hiding the persistence layer behind an abstract interface allows us to separate the higher-layer tests from a concrete implementation and thus from a database. This simplifies our test cases and accelerates their execution by several orders of magnitude. Use of the real implementation normally verifies only the methods specified in the persistence interface, which should be kept as small as possible. In addition, we should always strive for the simplest persistence technology within the context of a specific project.
Mock objects can be used to test an implementation built on JDBC, but often require too much work to be worthwhile. A few interaction tests between the persistence mechanism and higher-level objects are meaningful to ensure a basically functioning communication.