Develop the Data Access Tier

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

Next, we will look at the data access tier. We will start with a simple structure for the data access test and write the test case for the find all records operation.

Find all records operation

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

We will see how to write the data access operation for the above test. The @Repository annotation indicates that the class is a data access operation object, which is also eligible for component scanning.

The class level @Transactional annotation shows that ...