### Question:
BaseDao extends HibernateDaoSupport implements IBaseDao { @Override @SuppressWarnings("unchecked") public <X> X queryUniqueObject(String hql, Class<X> clazz) { List<X> list = (List<X>) query(hql); if (list == null || list.size() == 0) return null; if (list.size() == 1) return list.get(0); throw new NonUniqueObjectException(hql, clazz.getName()); }  @Autowired void setSuperSessionFactory(SessionFactory sessionFactory); @Override void saveOrUpdate(Object entity); @Override void save(Object entity); @Override void saveOrUpdate(Collection<?> co); @Override void update(Object entity); @Override void update(String hql); @Override void delete(Object entity); @Override void delete(String hql); @Override void deleteAll(Collection<?> collectionEntities); @Override void refresh(Object obj); @Override Object load(Class<?> clazz, Serializable id); @Override List<?> loadAll(Class<?> entityClass); @Override Object get(Class<?> clazz, Serializable id); @Override Object loadNotLazy(Class<?> clazz, Serializable id); @Override Iterator<?> iterate(String hql); @Override @SuppressWarnings("unchecked") X queryUniqueObject(String hql, Class<X> clazz); @Override List<?> query(String hql); @Override List<?> query(String hql, Object[] args, Type[] types); @Override List<?> query(String hql, Integer maxSize); @Override List<?> queryByNamedParam(String hql, String[] args, Object[] values); @Override List<?> findBySql(String sql, Object[] args, Type[] types); @Override List<?> findBySql(String sql, int count); @Override List<?> findBySql(String sql); @Override List<?> findBySql(String sql, Class<?> persistentClass, int count); @Override void clear(); @Override void evict(Object entity); @Override void flush(); @Override void evictSecondLevelCache(Class<?> persistentClass); @Override DataBaseType getDataBaseType();  }### Answer:
@Test public void testQueryUniqueObject() { String queryHql = "from TTestUser where name='" + testUserName + "'"; String id = ""; try { baseDao.queryUniqueObject(queryHql, TTestUser.class); } catch (NonUniqueObjectException e) { assertSame("name为：" + testUserName + "的记录不唯一！", e.getEntityName(), TTestUser.class.getName()); } try { for (String userId : getUserMap().keySet()) { id = userId; queryHql = "from TTestUser where id='" + id + "'"; baseDao.queryUniqueObject(queryHql, TTestUser.class); } } catch (NonUniqueObjectException e) { fail("id为：" + id + "的记录不唯一！"); } assertSame("queryUniqueObject错误！", getUserMap().size(), baseDao.loadAll(TTestUser.class).size()); }