GenericEntityService extends AbstractService<E, PK> implements GenericService<E, PK> { @Override @Transactional(readOnly = true) public E selectByPk(PK pk) { if (StringUtils.isEmpty(pk)) { return null; } return createQuery().where(GenericEntity.id, pk).single(); } @SuppressWarnings("unchecked")  GenericEntityService(); @Autowired(required = false) void setEventPublisher(ApplicationEventPublisher eventPublisher); @PostConstruct void init(); @Override E deleteByPk(PK pk); @Override int updateByPk(PK pk, E entity); @Override int updateByPk(List<E> data); @Override PK saveOrUpdate(E entity); @Override PK insert(E entity); @Override @Transactional(readOnly = true) E selectByPk(PK pk); @Override @Transactional(readOnly = true) List<E> selectByPk(List<PK> id);  }
@Test public void testQuery() { PagerResult<TestEntity> result = entityService.selectPager(queryParamEntity); Assert.assertEquals(result.getTotal(), 1); Assert.assertEquals(result.getData().size(), 1); TestEntity entity = entityService.selectByPk(result.getData().get(0).getId()); Assert.assertNotNull(entity); List<TestEntity> testEntities = entityService.selectByPk(Arrays.asList(result.getData().get(0).getId())); Assert.assertTrue(!testEntities.isEmpty()); }