### Question:
HibernateDocumentLinkDAO extends HibernatePersistentObjectDAO<DocumentLink> implements DocumentLinkDAO { @Override public boolean store(DocumentLink entity) throws PersistenceException { boolean newLink = entity.getId() == 0L; boolean result = super.store(entity); flush(); if (newLink && result) { if (entity.getDocument1() != null) updateLinksCount(entity.getDocument1().getId()); if (entity.getDocument2() != null) updateLinksCount(entity.getDocument2().getId()); } return result; } 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 testStore() throws PersistenceException { DocumentLink link = new DocumentLink(); Document doc1 = docDao.findById(1); Document doc2 = docDao.findById(2); link.setDocument1(doc1); link.setDocument2(doc2); link.setType("zzz"); dao.store(link); link = dao.findById(link.getId()); Assert.assertEquals(1, link.getDocument1().getId()); Assert.assertEquals(2, link.getDocument2().getId()); Assert.assertEquals("zzz", link.getType()); }