UserRepository extends BaseRepository<UserEntity, String> { @SuppressWarnings("unchecked") public List<UserEntity> selectByLastName(String lastName) { Query query = em() .createQuery("SELECT user FROM UserEntity user WHERE user.lastName = :lastName"); query.setParameter("lastName", lastName); return query.getResultList(); }  @Override Class<UserEntity> getEntityType(); @SuppressWarnings("unchecked") List<UserEntity> selectByLastName(String lastName);  }
@Test @Transactional(readOnly = true) public void testSelectByLastName() { UserEntity user = UserFactory.create(); user.setLastName(RandomStringUtils.randomAlphanumeric(32)); repo.create(user); List<UserEntity> result = repo.selectByLastName(user.getLastName()); assertThat("stored user last name", result.get(0).getLastName(), is(user.getLastName())); }