Develop the Business Service Tier
Let's see how the business service can be developed for a concrete table inheritance scenario.
We'll cover the following...
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 )@Transactionalpublic class EstateServiceImplTest {@Autowiredprivate EstateService service;@Testpublic 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@Transactionalpublic class EstateServiceImpl implements EstateService {@Autowiredprivate EstateDao estateDao;@Autowiredprivate EstateMapper estateMapper;@Overridepublic 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 ...