예제 #1
0
  public List findByRoleNameLike(String roleName) {

    Session session = HibernateTrain.getSession();
    Criteria criteria =
        session.createCriteria(StaffRole.class).add(Restrictions.like("roleName", roleName));
    return criteria.list();
  }
예제 #2
0
  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();
  }
예제 #3
0
  public void delete(StaffRole staffRole) {

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

    return HibernateTrain.getSession().load(StaffRole.class, pk);
  }
예제 #6
0
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();
  }
}