public List findByRoleNameLike(String roleName) {

    Session session = HibernateTrain.getSession();
    Criteria criteria =
        session.createCriteria(StaffRole.class).add(Restrictions.like("roleName", roleName));
    return criteria.list();
  }
  public List byExample(StaffRole staffRole) {

    Session session = HibernateTrain.getSession();
    Criteria cri = session.createCriteria(StaffRole.class);
    Example exam = Example.create(staffRole);
    cri.add(exam);
    return cri.list();
  }
  public void delete(StaffRole staffRole) {

    Session session = HibernateTrain.getSession();
    Transaction transaction = session.beginTransaction();
    transaction.begin();
    session.delete(staffRole);
    transaction.commit();
  }
 public List getAll() {
   Session session = HibernateTrain.getSession();
   Criteria criteria = session.createCriteria(StaffRole.class);
   return criteria.list();
 }
  public Object load(Integer pk) {

    return HibernateTrain.getSession().load(StaffRole.class, pk);
  }
public class CountriesDao {

  Session session = HibernateTrain.getSession();

  public CountriesDao() {}

  public void create(Countries countries) {

    Transaction transaction = session.beginTransaction();
    transaction.begin();
    session.save(countries);
    transaction.commit();
  }

  public void update(Countries countries) {

    Transaction transaction = session.beginTransaction();
    transaction.begin();
    session.update(countries);
    transaction.commit();
  }

  public void delete(Countries countries) {

    Transaction transaction = session.beginTransaction();
    transaction.begin();
    session.evict(countries);
    session.delete(countries);
    transaction.commit();
  }

  public Countries load(String pk) {

    return (Countries) session.load(Countries.class, pk);
  }

  public List getAll() {

    Criteria criteria = session.createCriteria(Countries.class);
    return criteria.list();
  }

  public List findByCountryNameLike(String countryName) {

    Criteria criteria =
        session.createCriteria(Countries.class).add(Restrictions.like("countryName", countryName));
    return criteria.list();
  }

  public List regionsByExample(Countries countries) {

    Criteria cri = session.createCriteria(Countries.class);
    Example exam = Example.create(countries);
    cri.add(exam);
    return cri.list();
  }

  public void closeSession() {
    session.close();
  }
}