TableDao { public long countBySample(T sample, Hints...hints) throws SQLException { return client.countBySample(sample, hints); } TableDao(String logicDbName, Class<T> entityType); T queryByPk(T pk, Hints...hints); List<T> queryBySample(T sample, Hints...hints); List<T> queryBySample(T sample, PageRange range, Hints...hints); long countBySample(T sample, Hints...hints); int insert(T entity, Hints...hints); int insert(List<T> entities, Hints...hints); int[] batchInsert(List<T> entities, Hints...hints); int deleteByPk(T pk, Hints...hints); int deleteBySample(T sample, Hints...hints); int[] batchDelete(List<T> entities, Hints...hints); int update(T entity, Hints...hints); int[] batchUpdate(List<T> entities, Hints...hints);  }
@Test public void testCountBySample() throws Exception { Person pk = new Person(); pk.setName("test"); assertEquals(4, dao.countBySample(pk)); for(int j = 0; j < TABLE_MODE;j++) { pk = new Person(); pk.setPeopleID(j+1); assertEquals(1, dao.countBySample(pk)); pk = new Person(); pk.setCountryID(j); pk.setCityID(j); assertEquals(1, dao.countBySample(pk)); } }