@Override
  public Spell findByName(String name) {
    Transaction tx = null;
    Spell result;
    try (var session = getSessionFactory().openSession()) {
      tx = session.beginTransaction();
      CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
      CriteriaQuery<Spell> builderQuery = criteriaBuilder.createQuery(Spell.class);
      Root<Spell> root = builderQuery.from(Spell.class);
      builderQuery.select(root).where(criteriaBuilder.equal(root.get("name"), name));
      Query<Spell> query = session.createQuery(builderQuery);
      result = query.uniqueResult();
      tx.commit();
    } catch (Exception e) {
      if (tx != null) {
        tx.rollback();
      }
      throw e;
    }
    return result;
  }
@Test
  void testFindByName() {
    final var dao = getDao();
    final var allSpells = dao.findAll();
    for (final var spell : allSpells) {
      final var spellByName = dao.findByName(spell.getName());
      assertNotNull(spellByName);
      assertEquals(spell.getId(), spellByName.getId());
      assertEquals(spell.getName(), spellByName.getName());
    }
  }