Develop the Data Access Tier

The data access tier is the second step in the process of developing a service.

Next, we will look at the data access tier. We will start with the test case for the “find all records” operation. Since this is the first function that is being developed as part of the test-driven development, we let it return zero for the find all records operation. In the following functions, we will build the CRUD operations in sequence.

Find all records operation

Press + to interact
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath:context.xml" } )
@TransactionConfiguration( defaultRollback = true )
@Transactional
public class BookDaoImplTest {
@Autowired
private BookDao dao;
@Test
public void testGetAll() {
Assert.assertEquals(0L, dao.getAll().size());
}
}

We will see how to write the conforming data access operation for the test above. The BookDao is an ...