...

/

Develop the Business Service Tier

Develop the Business Service Tier

Let's see how the business service can be developed for a concrete table inheritance scenario.

Find all records operation

We will proceed with the “find all records” operation.

Press + to interact
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath:context.xml" } )
@TransactionConfiguration( defaultRollback = true )
@Transactional
public class EstateServiceImplTest {
@Autowired
private EstateService service;
@Test
public void testFindAll() {
Assert.assertEquals(0L, service.findAll().size());
}
}

Let’s look at how to code the corresponding “find all records” operation in the business service.

Press + to interact
@Service
@Transactional
public class EstateServiceImpl implements EstateService {
@Autowired
private EstateDao estateDao;
@Autowired
private EstateMapper estateMapper;
@Override
public List<EstateDto> findAll() {
List<Estate> estates = estateDao.getAll();
List<EstateDto> estateDtos = new ArrayList<EstateDto>();
for(Estate estate : estates){
estateDtos.add(estateMapper.mapEntityToDto(estate));
}
return estateDtos;
}
}

Mappers

The mapper has two vital operations which are used to convert data access objects to ...