@Override
  public void addWordToUser(final User user, final Word word) {
    final UserEntity userEntity = getUserEntity(user.getEmail());
    final WordEntity wordEntity = dictionaryDaoHibernate.registerWord(word);

    sessionFactory.getCurrentSession().save(new UserWordEntity(userEntity, wordEntity));
  }
 @Override
 public void removeWord(final User user, final Word word) {
   sessionFactory
       .getCurrentSession()
       .createQuery(
           "delete UserWordEntity where userEntity = :userEntity "
               + "and wordEntity = :wordEntity")
       .setParameter("userEntity", getUserEntity(user.getEmail()))
       .setParameter("wordEntity", dictionaryDaoHibernate.registerWord(word))
       .executeUpdate();
 }
  @Override
  public List<Word> getWords(final User user) {
    @SuppressWarnings("unchecked")
    final List<UserWordEntity> userEntities =
        sessionFactory
            .getCurrentSession()
            .createQuery("from UserWordEntity where userEntity = :userEntity")
            .setParameter("userEntity", getUserEntity(user.getEmail()))
            .list();

    return userEntities
        .stream()
        .map(userWordEntity -> translateToWord(userWordEntity.getWordEntity()))
        .collect(Collectors.toList());
  }
 @Override
 public void addUser(final User user) {
   if (getUser(user.getEmail()) == null) {
     sessionFactory.getCurrentSession().save(new UserEntity(user.getEmail()));
   }
 }