本文整理汇总了Java中org.hibernate.Criteria.list方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.list方法的具体用法?Java Criteria.list怎么用?Java Criteria.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.Criteria
的用法示例。
在下文中一共展示了Criteria.list方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showBookByDynasty
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public Pager<Book> showBookByDynasty(String dynasty, int pageNo,int pageSize) {
System.out.println("-----执行到BookDaoImpl");
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(Book.class);
criteria.add(Restrictions.eq("dynasty", dynasty));
long recordTotal = ((Long) criteria.setProjection(Projections.rowCount()).uniqueResult()).longValue();
criteria.setProjection(null);
criteria.addOrder(Order.desc("clickTimes"));
criteria.setFirstResult((pageNo - 1) * pageSize);
criteria.setMaxResults(pageSize);
List<Book> results = criteria.list();
Pager<Book> page=new Pager<Book>(pageSize, pageNo, recordTotal, results);
return page;
}
示例2: getKeysImpl
import org.hibernate.Criteria; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected Collection<String> getKeysImpl(Session session, Long piid, String prefix, Type type) throws HibernateException {
if( piid == null )
return Collections.EMPTY_LIST;
Criteria criteria = session.createCriteria(getPersistentClass())
.add(Restrictions.eq("processInstanceId", piid))
.setProjection(Projections.property("key"));
if (prefix != null)
criteria.add(Restrictions.ilike("key", prefix, MatchMode.START));
if(type != null)
criteria.add(Restrictions.eq("type", type.getValue()));
return criteria.list();
}
示例3: searchByTitle
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public Pager<Book> searchByTitle(String title, int pageNo, int pageSize) {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(Book.class);
criteria.add(Restrictions.like("bookTitle", "%"+title+"%"));
long recordTotal = ((Long) criteria.setProjection(Projections.rowCount()).uniqueResult()).longValue();
criteria.setProjection(null);
// criteria.addOrder(Order.desc("clickTimes"));
criteria.setFirstResult((pageNo - 1) * pageSize);
criteria.setMaxResults(pageSize);
List<Book> results = criteria.list();
System.out.println(results.size()+"-------数据多少");
Pager<Book> page=new Pager<Book>(pageSize, pageNo, recordTotal, results);
return page;
}
示例4: handleFindByProbandCalendarInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
* @inheritDoc
*/
@Override
protected Collection<InventoryBooking> handleFindByProbandCalendarInterval(Long probandId, String calendar, Timestamp from, Timestamp to,
Boolean isRelevantForProbandAppointments) throws Exception
{
Criteria bookingCriteria = createBookingCriteria();
CriteriaUtil.applyClosedIntervalCriterion(bookingCriteria, from, to, null);
if (probandId != null) {
bookingCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
}
if (isRelevantForProbandAppointments != null) {
bookingCriteria.createCriteria("inventory", CriteriaSpecification.INNER_JOIN).createCriteria("category", CriteriaSpecification.INNER_JOIN)
.add(Restrictions.eq("relevantForProbandAppointments", isRelevantForProbandAppointments.booleanValue()));
}
CategoryCriterion.apply(bookingCriteria, new CategoryCriterion(calendar, "calendar", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
return bookingCriteria.list();
}
示例5: getTopicByCondition
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<?> getTopicByCondition (Topic topic) {
Session session = sessionFactory.getCurrentSession();
Criteria c = session.createCriteria(Topic.class);
if (topic != null) {
if (topic.getName() != null && !"".equals(topic.getName())) {
c.add(Restrictions.like("name", topic.getName(), MatchMode.ANYWHERE));
}
}
return c.list();
}
示例6: handleFindByAppointmentDepartmentsCalendarInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<InventoryBooking> handleFindByAppointmentDepartmentsCalendarInterval(Long probandDepartmentId, Long courseDepartmentId, Long trialDepartmentId,
String calendar, Timestamp from, Timestamp to,
Boolean isProbandAppointment, Boolean isRelevantForProbandAppointments,
Boolean isCourseAppointment, Boolean isRelevantForCourseAppointments,
Boolean isTrialAppointment, Boolean isRelevantForTrialAppointments) throws Exception
{
Criteria bookingCriteria = createBookingCriteria();
CriteriaUtil.applyClosedIntervalCriterion(bookingCriteria, from, to, null);
if (probandDepartmentId != null) {
bookingCriteria.createCriteria("proband", CriteriaSpecification.LEFT_JOIN).add(
Restrictions.or(Restrictions.isNull("department.id"), Restrictions.eq("department.id", probandDepartmentId.longValue())));
}
if (courseDepartmentId != null) {
bookingCriteria.createCriteria("course", CriteriaSpecification.LEFT_JOIN).add(
Restrictions.or(Restrictions.isNull("department.id"), Restrictions.eq("department.id", courseDepartmentId.longValue())));
}
if (trialDepartmentId != null) {
bookingCriteria.createCriteria("trial", CriteriaSpecification.LEFT_JOIN).add(
Restrictions.or(Restrictions.isNull("department.id"), Restrictions.eq("department.id", trialDepartmentId.longValue())));
}
applyIncludeAppointmentsCriterion(bookingCriteria,isProbandAppointment,"proband.id",isRelevantForProbandAppointments,"relevantForProbandAppointments");
applyIncludeAppointmentsCriterion(bookingCriteria,isCourseAppointment,"course.id",isRelevantForCourseAppointments,"relevantForCourseAppointments");
applyIncludeAppointmentsCriterion(bookingCriteria,isTrialAppointment,"trial.id",isRelevantForTrialAppointments,"relevantForTrialAppointments");
CategoryCriterion.apply(bookingCriteria, new CategoryCriterion(calendar, "calendar", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
bookingCriteria.addOrder(Order.asc("start"));
return bookingCriteria.list();
}
示例7: findAllUsers
import org.hibernate.Criteria; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<AdmUser> findAllUsers() {
Criteria criteria = createEntityCriteria().addOrder(Order.asc("firstName"));
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);//To avoid duplicates.
List<AdmUser> users = (List<AdmUser>) criteria.list();
// No need to fetch userProfiles since we are not showing them on list page. Let them lazy load.
// Uncomment below lines for eagerly fetching of userProfiles if you want.
/*
for(User user : users){
Hibernate.initialize(user.getUserProfiles());
}*/
return users;
}
示例8: handleFindCalendars
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<String> handleFindCalendars(Long trialDepartmentId,
Long staffId, Long trialId, String calendarPrefix, Integer limit)
throws Exception {
Criteria dutyRosterCriteria = createDutyRosterTurnCriteria("dutyRosterTurn");
Criteria trialCriteria = null;
if (trialDepartmentId != null) {
trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.LEFT_JOIN);
} else if (trialId != null) {
trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.INNER_JOIN);
}
if (trialDepartmentId != null || trialId != null) {
if (trialDepartmentId != null) {
trialCriteria.add(Restrictions.or(Restrictions.isNull("dutyRosterTurn.trial"), Restrictions.eq("department.id", trialDepartmentId.longValue())));
}
if (trialId != null) {
trialCriteria.add(Restrictions.idEq(trialId.longValue()));
}
}
if (staffId != null) {
dutyRosterCriteria.add(Restrictions.eq("staff.id", staffId.longValue()));
}
CategoryCriterion.apply(dutyRosterCriteria, new CategoryCriterion(calendarPrefix, "calendar", MatchMode.START));
dutyRosterCriteria.addOrder(Order.asc("calendar"));
dutyRosterCriteria.setProjection(Projections.distinct(Projections.property("calendar")));
CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.DUTY_ROSTER_TURN_CALENDAR_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
DefaultSettings.DUTY_ROSTER_TURN_CALENDAR_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), dutyRosterCriteria);
return dutyRosterCriteria.list();
}
示例9: handleFindByDepartmentCategoryInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
* @inheritDoc
*/
@Override
protected Collection<ProbandStatusEntry> handleFindByDepartmentCategoryInterval(Long departmentId, Long probandCategoryId, Timestamp from, Timestamp to, Boolean probandActive,
Boolean available, Boolean hideAvailability)
{
Criteria statusEntryCriteria = createStatusEntryCriteria();
CriteriaUtil.applyStopOpenIntervalCriterion(statusEntryCriteria, from, to, null);
if (probandActive != null || hideAvailability != null) {
Criteria typeCriteria = statusEntryCriteria.createCriteria("type", CriteriaSpecification.INNER_JOIN);
if (probandActive != null) {
typeCriteria.add(Restrictions.eq("probandActive", probandActive.booleanValue()));
}
if (hideAvailability != null) {
typeCriteria.add(Restrictions.eq("hideAvailability", hideAvailability.booleanValue()));
}
}
if (departmentId != null || available != null) {
Criteria probandCriteria = statusEntryCriteria.createCriteria("proband", CriteriaSpecification.INNER_JOIN);
if (departmentId != null) {
probandCriteria.add(Restrictions.eq("department.id", departmentId.longValue()));
}
if (probandCategoryId != null) {
probandCriteria.add(Restrictions.eq("category.id", probandCategoryId.longValue()));
}
if (available != null) {
probandCriteria.add(Restrictions.eq("available", available.booleanValue()));
}
}
return statusEntryCriteria.list();
}
示例10: findAll
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<T> findAll(final PageRequest pageRequest, final List<PropertyFilter> filters) {
Criterion[] criterions = buildCriterionByPropertyFilter(filters);
Criteria c = createCriteria(criterions);
if (pageRequest.isOrderBySetted()) {
for (PageRequest.Sort sort : pageRequest.getSort()) {
if (PageRequest.Sort.ASC.equals(sort.getDir())) {
c.addOrder(Order.asc(sort.getProperty()));
} else {
c.addOrder(Order.desc(sort.getProperty()));
}
}
}
return c.list();
}
示例11: handleFindByInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<VisitScheduleItem> handleFindByInterval(Long trialId, Long groupId,
Timestamp from, Timestamp to) throws Exception {
Criteria visitScheduleItemCriteria = createVisitScheduleItemCriteria(null);
CriteriaUtil.applyClosedIntervalCriterion(visitScheduleItemCriteria, from, to, null);
if (trialId != null) {
visitScheduleItemCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
}
if (groupId != null) {
visitScheduleItemCriteria.add(Restrictions.or(Restrictions.eq("group.id", groupId.longValue()),
Restrictions.isNull("group.id")));
}
return visitScheduleItemCriteria.list();
}
示例12: showBookByStyle
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public Pager<Book> showBookByStyle(String style, int pageNo, int pageSize) {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(Book.class);
criteria.add(Restrictions.eq("bookStyle", style));
long recordTotal = ((Long) criteria.setProjection(Projections.rowCount()).uniqueResult()).longValue();
criteria.setProjection(null);
criteria.addOrder(Order.desc("clickTimes"));
criteria.setFirstResult((pageNo - 1) * pageSize);
criteria.setMaxResults(pageSize);
List<Book> results = criteria.list();
Pager<Book> page=new Pager<Book>(pageSize, pageNo, recordTotal, results);
return page;
}
示例13: execute
import org.hibernate.Criteria; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<TaskReminder> execute(Context context) {
Criteria criteria=context.getSession().createCriteria(TaskReminder.class);
if(taskId>0){
criteria.add(Restrictions.eq("taskId",taskId));
}
return criteria.list();
}
示例14: handleFindByDepartmentCategoryCalendarInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
* @inheritDoc
*/
@Override
protected Collection<DutyRosterTurn> handleFindByDepartmentCategoryCalendarInterval(Long staffDepartmentId, Long staffCategoryId, Boolean allocatable, String calendar,
Timestamp from, Timestamp to)
{
Criteria dutyRosterCriteria = createDutyRosterTurnCriteria("dutyRosterTurn");
CriteriaUtil.applyClosedIntervalCriterion(dutyRosterCriteria, from, to, null);
Criteria staffCriteria = null;
if (staffDepartmentId != null) {
staffCriteria = dutyRosterCriteria.createCriteria("staff", CriteriaSpecification.LEFT_JOIN);
} else if (staffCategoryId != null || allocatable != null) {
staffCriteria = dutyRosterCriteria.createCriteria("staff", CriteriaSpecification.INNER_JOIN);
}
if (staffDepartmentId != null || staffCategoryId != null || allocatable != null) {
if (staffDepartmentId != null) {
staffCriteria.add(Restrictions.or(Restrictions.isNull("dutyRosterTurn.staff"), Restrictions.eq("department.id", staffDepartmentId.longValue())));
}
if (staffCategoryId != null) {
staffCriteria.add(Restrictions.eq("category.id", staffCategoryId.longValue()));
}
if (allocatable != null) {
staffCriteria.add(Restrictions.eq("allocatable", allocatable.booleanValue()));
}
}
CategoryCriterion.apply(dutyRosterCriteria, new CategoryCriterion(calendar, "calendar", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
return dutyRosterCriteria.list();
}
示例15: search
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<?> search(Admin admin) {
Session session = sessionFactory.getCurrentSession();
Criteria c = session.createCriteria(Admin.class);
// 创建示例条件
Example example = Example.create(admin);
c.add(example);
return c.list();
}