Example usage for org.hibernate Criteria list

List of usage examples for org.hibernate Criteria list

Introduction

In this page you can find the example usage for org.hibernate Criteria list.

Prototype

public List list() throws HibernateException;

Source Link

Document

Get the results.

Usage

From source file:abm.jakaria.school.ContractusDao.java

@SuppressWarnings("unchecked")
public List<Contractus> getAllContractus() {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Contractus.class);
    return criteria.list();
}

From source file:abm.jakaria.school.EmployeeDao.java

@SuppressWarnings("unchecked")
public List<Employee> searchEmployee(String name) {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Employee.class);
    criteria.add(Restrictions.ilike("name", name + "%"));
    return criteria.list();
}

From source file:abm.jakaria.school.EmployeeDao.java

@SuppressWarnings("unchecked")
public List<Employee> getAllEmployee() {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Employee.class);
    return criteria.list();
}

From source file:abm.jakaria.school.ResultDao.java

@SuppressWarnings("unchecked")
public List<Result> searchResult(String name) {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Result.class);
    criteria.add(Restrictions.ilike("name", name + "%"));
    return criteria.list();
}

From source file:abm.jakaria.school.ResultDao.java

@SuppressWarnings("unchecked")
public List<Result> getAllResult() {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Result.class);
    return criteria.list();
}

From source file:abm.jakaria.school.StudentDao.java

@SuppressWarnings("unchecked")
public List<Student> searchStudent(String name) {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Student.class);
    criteria.add(Restrictions.ilike("name", name + "%"));
    return criteria.list();
}

From source file:abm.jakaria.school.StudentDao.java

@SuppressWarnings("unchecked")
public List<Student> getAllStudent() {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Student.class);
    return criteria.list();
}

From source file:Action.StockManagement.java

public String viewStock() throws NullPointerException {
    Session s = HibernateUtil.getSession();
    Transaction t = s.beginTransaction();

    Criteria c = s.createCriteria(Current_Stock.class);
    c.setFirstResult(0);/*from  w w  w  .  ja  v  a2  s . co m*/
    c.setMaxResults(10);
    List<Current_Stock> list = c.list();
    getReq().setAttribute("cs", list);

    /* Query q=s.createQuery(" from Current_Stock"); 
    List<Current_Stock> data=q.list();
    req.setAttribute("cs",data);
    int i=0;
    req.setAttribute("next",i);*/

    t.commit();
    return "success";
}

From source file:Action.StockManagement.java

public String viewNext() throws NullPointerException {
    Session s = HibernateUtil.getSession();
    Transaction t = s.beginTransaction();

    // int i=Integer.parseInt(req.getParameter("first"));
    Criteria c = s.createCriteria(Current_Stock.class);
    c.setFirstResult(10);/*from ww w. ja va2  s.  c om*/
    c.setMaxResults(10);
    List<Current_Stock> list = c.list();
    getReq().setAttribute("cs", list);

    // req.setAttribute("first",i+2);
    /* Query q=s.createQuery(" from Current_Stock"); 
    List<Current_Stock> data=q.list();
    req.setAttribute("cs",data);
    int i=0;
    req.setAttribute("next",i);*/

    t.commit();
    return "success";
}

From source file:Activity.activityGetter.java

public static Activity[] getActivities() {

    //create SessionFactory object for opening Session
    //SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
    Session session;//from w w  w .ja  v  a 2  s  .  com
    //Criteria requires a transaction opened
    session = HibernateUtil.getSessionFactory().openSession();
    //create Criteria for Customer class
    Criteria criteria = session.createCriteria(Activity.class);
    //add a Restriction which will be used for equality > state = MI
    //criteria.add(Restrictions.eq(state?, stateName));
    //add an order for using customer_ID column
    //criteria.addOrder(Order.asc(customer_ID?));
    //return the resultset as a List
    List<Activity> Activityresult = criteria.list();

    //convert List to Array
    return Activityresult.toArray(new Activity[Activityresult.size()]);

}