### Question:
HibernateDocumentLinkDAO extends HibernatePersistentObjectDAO<DocumentLink> implements DocumentLinkDAO { @Override public DocumentLink findByDocIdsAndType(long docId1, long docId2, String type) { if (type == null) return null; DocumentLink link = null; StringBuffer query = new StringBuffer("_entity.document1.id = ?1 and _entity.document2.id = ?2 "); query.append("and _entity.type = '"); query.append(type); query.append("'"); List<DocumentLink> links = new ArrayList<DocumentLink>(); try { links = findByWhere(query.toString(), new Object[] { docId1, docId2 }, null, null); } catch (PersistenceException e) { log.error(e.getMessage(), e); } if (!links.isEmpty()) link = links.iterator().next(); return link; } HibernateDocumentLinkDAO(); @Override List<DocumentLink> findByDocId(long docId); @Override List<DocumentLink> findByDocId(long docId, String type); @Override DocumentLink findByDocIdsAndType(long docId1, long docId2, String type); @Override boolean delete(long id, int code); @Override boolean store(DocumentLink entity);  }### Answer:
@Test public void testFindByDocIdsAndType() { DocumentLink link = dao.findByDocIdsAndType(1, 2, "test"); Assert.assertNotNull(link); Assert.assertEquals(1, link.getId()); link = dao.findByDocIdsAndType(2, 1, "xyz"); Assert.assertNotNull(link); Assert.assertEquals(2, link.getId()); link = dao.findByDocIdsAndType(1, 2, "xxx"); Assert.assertNotNull(link); Assert.assertEquals(3, link.getId()); link = dao.findByDocIdsAndType(2, 1, ""); Assert.assertNotNull(link); Assert.assertEquals(4, link.getId()); link = dao.findByDocIdsAndType(2, 1, null); Assert.assertNull(link); link = dao.findByDocIdsAndType(1, 2, "zzz"); Assert.assertNull(link); }