### Question:
HibernateGenericDAO extends HibernatePersistentObjectDAO<Generic> implements GenericDAO { @Override public Generic findByAlternateKey(String type, String subtype, Long qualifier, long tenantId) { Generic generic = null; StringBuffer sb = new StringBuffer(" _entity.type = '" + SqlUtil.doubleQuotes(type) + "' and _entity.subtype='" + SqlUtil.doubleQuotes(subtype) + "' "); sb.append(" and _entity.tenantId=" + tenantId); if (qualifier != null) sb.append(" and _entity.qualifier=" + qualifier); else sb.append(" and _entity.qualifier is null"); try { Collection<Generic> coll = findByWhere(sb.toString(), null, null); if (coll.size() > 0) generic = coll.iterator().next(); } catch (PersistenceException e) { log.error(e.getMessage(), e); } return generic; } HibernateGenericDAO(); @Override boolean delete(long genericId, int code); @Override Generic findByAlternateKey(String type, String subtype, Long qualifier, long tenantId); @Override List<Generic> findByTypeAndSubtype(String type, String subtype, Long qualifier, Long tenantId); @Override void initialize(Generic generic); @Override boolean store(Generic entity);  }### Answer:
@Test public void testFindByAlternateKey() { Generic generic = dao.findByAlternateKey("a", "a1", null, Tenant.DEFAULT_ID); Assert.assertNotNull(generic); Assert.assertEquals(new Long(0), generic.getInteger1()); generic = dao.findByAlternateKey("a", "xxx", null, 99L); Assert.assertNull(generic); }