List of usage examples for org.hibernate Criteria list
public List list() throws HibernateException;
From source file:abid.password.swing.dao.hibernate.AbstractHibernateDao.java
License:Apache License
@SuppressWarnings("rawtypes") public int countAll() { Session session = sessionFactory.openSession(); try {// ww w. j a v a 2 s. c o m Criteria criteria = session.createCriteria(persistentClass); criteria.setProjection(Projections.rowCount()); List result = criteria.list(); Long rowCount = (Long) result.get(0); int count = rowCount.intValue(); // return ( Long ) criteria.uniqueResult( ); return count; } finally { session.close(); } }
From source file:abid.password.swing.dao.hibernate.AbstractHibernateDao.java
License:Apache License
@SuppressWarnings("unchecked") protected List<T> findByCriteria(Criterion... criterion) { Session session = sessionFactory.openSession(); try {//from w w w . ja v a2 s . c o m Criteria criteria = session.createCriteria(getPersistentClass()); criteria.setCacheable(true); for (Criterion c : criterion) { criteria.add(c); } return criteria.list(); } finally { session.close(); } }
From source file:abid.password.wicket.dao.AbstractHibernateDao.java
License:Apache License
@Transactional(type = TransactionType.READ_ONLY) @SuppressWarnings("unchecked") public List<T> getAll() { Criteria criteria = session.get().createCriteria(persistentClass); List<T> list = (List<T>) criteria.list(); return list;/* w w w . ja v a2 s. c o m*/ }
From source file:abid.password.wicket.dao.AbstractHibernateDao.java
License:Apache License
@Transactional(type = TransactionType.READ_ONLY) @SuppressWarnings("unchecked") public List<T> get(int first, int fetchSize) { Criteria criteria = session.get().createCriteria(persistentClass); criteria.setFirstResult(first);//from ww w. j a v a 2 s. c o m criteria.setMaxResults(fetchSize); criteria.setFetchSize(fetchSize); criteria.setCacheable(true); List<T> dataList = (List<T>) criteria.list(); return dataList; }
From source file:abid.password.wicket.dao.AbstractHibernateDao.java
License:Apache License
@Transactional(type = TransactionType.READ_ONLY) @SuppressWarnings("unchecked") public List<T> getSorted(int first, int fetchSize, String propertyName, boolean ascending) { Criteria criteria = session.get().createCriteria(persistentClass); criteria.setFirstResult(first);/*from ww w .j a v a 2 s. c o m*/ criteria.setMaxResults(fetchSize); criteria.setFetchSize(fetchSize); criteria.setCacheable(true); if (ascending) { criteria.addOrder(Order.asc(propertyName)); } else { criteria.addOrder(Order.desc(propertyName)); } List<T> dataList = (List<T>) criteria.list(); return dataList; }
From source file:abid.password.wicket.dao.AbstractHibernateDao.java
License:Apache License
@Transactional(type = TransactionType.READ_ONLY) @SuppressWarnings("rawtypes") public int countAll() { Criteria criteria = session.get().createCriteria(persistentClass); criteria.setProjection(Projections.rowCount()); List result = criteria.list(); Long rowCount = (Long) result.get(0); int count = rowCount.intValue(); // return ( Long ) criteria.uniqueResult( ); return count; }
From source file:abid.password.wicket.dao.AbstractHibernateDao.java
License:Apache License
@Transactional(type = TransactionType.READ_ONLY) @SuppressWarnings("unchecked") protected List<T> findByCriteria(Criterion... criterion) { Criteria criteria = session.get().createCriteria(getPersistentClass()); criteria.setCacheable(true);/*from ww w. jav a 2 s. c om*/ for (Criterion c : criterion) { criteria.add(c); } return criteria.list(); }
From source file:abm.jakaria.school.CommiteeDao.java
@SuppressWarnings("unchecked") public List<Commitee> searchCommitee(String name) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Commitee.class); criteria.add(Restrictions.ilike("name", name + "%")); return criteria.list(); }
From source file:abm.jakaria.school.CommiteeDao.java
@SuppressWarnings("unchecked") public List<Commitee> getAllCommitee() { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Commitee.class); return criteria.list(); }
From source file:abm.jakaria.school.ContractusDao.java
@SuppressWarnings("unchecked") public List<Contractus> searchContractus(String name) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Contractus.class); criteria.add(Restrictions.ilike("name", name + "%")); return criteria.list(); }