@Override
  public Wizard findByName(String name) {
    Transaction tx = null;
    Wizard result;
    try (var session = getSessionFactory().openSession()) {
      tx = session.beginTransaction();
      CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
      CriteriaQuery<Wizard> builderQuery = criteriaBuilder.createQuery(Wizard.class);
      Root<Wizard> root = builderQuery.from(Wizard.class);
      builderQuery.select(root).where(criteriaBuilder.equal(root.get("name"), name));
      Query<Wizard> 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 allWizards = dao.findAll();
    for (final var spell : allWizards) {
      final var byName = dao.findByName(spell.getName());
      assertNotNull(byName);
      assertEquals(spell.getId(), byName.getId());
      assertEquals(spell.getName(), byName.getName());
    }
  }