MentionableDAO implements IMentionableDAO<K, T> { @Override public void persistValue(T value) { EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction transaction = entityManager.getTransaction(); transaction.begin(); try { entityManager.persist(value); transaction.commit(); } catch (PersistenceException e) { if (isEntityAlreadyExists(value)) { closeEntityManager(entityManager); throw new EntityExistsException(e.getCause()); } LOG.error("Cannot store {}. {}", value, e.getMessage()); } if (transaction.isActive() && transaction.getRollbackOnly()) { transaction.rollback(); } closeEntityManager(entityManager); } protected  MentionableDAO(EntityManagerFactory entityManagerFactory, Class<T> type); @Override void persistValue(T value); @Override T getValue(T value); @Override List<T> getAllMentionsForValue(K value, Interval interval,
                                          List<String> roomNames, List<String> usernames); @Override List<T> getAllMentions(Interval interval, List<String> roomNames,
                                  List<String> usernames,
                                  boolean withBots); List<T> internalGetAllMentionsForValue(Optional<K> value,
                                                  Interval interval,
                                                  List<String> roomNames,
                                                  List<String> usernames,
                                                  boolean withBots); @Override LabeledDenseMatrix<String> getRoomSimilaritiesByValue(Interval interval,
                                                                 boolean withBots); @Override LabeledDenseMatrix<String> getUserSimilaritiesByValue(Interval interval,
                                                                 boolean withBots); @Override int getTotalMentionsForType(K value, Interval interval, List<String> roomNames,
                                       List<String> usernames, boolean withBots); @Override int getTotalMentionsOfType(Interval interval,
                                      List<String> roomNames,
                                      List<String> usernames,
                                      boolean withBots); @Override Map<K, Long> getTopValuesOfType(Interval interval,
                                           List<String> roomNames,
                                           List<String> usernames,
                                           int resultSize,
                                           boolean withBots); @Override Map<String, Double> getActiveColumnsByToTV(String columnName, Interval interval,
                                                      int resultSize, boolean withBots); @Override Map<String, Double> getActiveColumnsByToMV(String columnName, Interval interval,
                                                      int resultSize, boolean withBots); @Override Class<T> getType(); @Override void close();  }
@Test public void testPersistValue() { DateTime dateTime = DateTime.now(); EmojiEntity emoji = new EmojiEntity("u1", "r1", dateTime, "a", 1, false); assertNull(underTest.getValue(emoji)); underTest.persistValue(emoji); assertNotNull(underTest.getValue(emoji)); }