本文整理汇总了Java中org.hibernate.Criteria.createCriteria方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.createCriteria方法的具体用法?Java Criteria.createCriteria怎么用?Java Criteria.createCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.Criteria
的用法示例。
在下文中一共展示了Criteria.createCriteria方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: countForSearchingRolling
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public long countForSearchingRolling(Short catalog, Integer subCatalog, String keywords) {
Criteria cri = getSession().createCriteria(Rollinfo.class);
Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
if (catalog != null) {
appCriteria.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
}
if (keywords != null && !keywords.isEmpty()) {
appCriteria.add(Restrictions.like("name", keywords, MatchMode.START));
}
cri.setProjection(Projections.rowCount());
List<Long> list = HibernateHelper.list(cri);
return list.get(0);
}
示例2: searchForRolling
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<Rollinfo> searchForRolling(Short catalog, Integer subCatalog, int page, int rows, String keywords,
String sort, String order) {
Criteria cri = getSession().createCriteria(Rollinfo.class);
Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
if (catalog != null) {
appCriteria.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
}
if (keywords != null && !keywords.isEmpty()) {
appCriteria.add(Restrictions.like("name", keywords, MatchMode.START));
}
if (sort != null && !sort.isEmpty()) {
HibernateHelper.addOrder(appCriteria, sort, order);
}
cri.setMaxResults(rows);
cri.setFirstResult(HibernateHelper.firstResult(page, rows));
List<Rollinfo> list = HibernateHelper.list(cri);
return list;
}
示例3: searchForRolling
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<Rollinfo> searchForRolling(Short catalog, Integer subCatalog, int page, int rows, String keywords,
String sort, String order) {
Criteria cri = getSession().createCriteria(Rollinfo.class);
Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
if (catalog != null) {
appCriteria.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
}
if (keywords != null && !keywords.isEmpty()) {
appCriteria.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
}
if (sort != null && !sort.isEmpty()) {
HibernateHelper.addOrder(appCriteria, sort, order);
}
cri.setMaxResults(rows);
cri.setFirstResult(HibernateHelper.firstResult(page, rows));
List<Rollinfo> list = HibernateHelper.list(cri);
return list;
}
示例4: countForSearchingRolling
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public long countForSearchingRolling(Short catalog, Integer subCatalog, String keywords) {
Criteria cri = getSession().createCriteria(Rollinfo.class);
Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
if (catalog != null) {
appCriteria.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
}
if (keywords != null && !keywords.isEmpty()) {
appCriteria.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
}
cri.setProjection(Projections.rowCount());
List<Long> list = HibernateHelper.list(cri);
return list.get(0);
}
示例5: handleFindMaintenanceInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<MaintenanceScheduleItem> handleFindMaintenanceInterval(
Long inventoryId, Long departmentId,
Long inventoryCategoryId, Long responsiblePersonId,
Boolean reminder, Timestamp from, Timestamp to) throws Exception {
Criteria maintenanceItemCriteria = createMaintenanceItemCriteria();
if (inventoryId != null || departmentId != null || inventoryCategoryId != null) {
Criteria inventoryCriteria = maintenanceItemCriteria.createCriteria("inventory", CriteriaSpecification.INNER_JOIN);
if (inventoryId != null) {
inventoryCriteria.add(Restrictions.idEq(inventoryId.longValue()));
}
if (departmentId != null) {
inventoryCriteria.add(Restrictions.eq("department.id", departmentId.longValue()));
}
if (inventoryCategoryId != null) {
inventoryCriteria.add(Restrictions.eq("category.id", inventoryCategoryId.longValue()));
}
}
if (responsiblePersonId != null) {
maintenanceItemCriteria.add(Restrictions.eq("responsiblePerson.id", responsiblePersonId.longValue()));
}
maintenanceItemCriteria.add(Restrictions.eq("active", true)); // performance only...
return CriteriaUtil.listEvents(maintenanceItemCriteria, from, to, reminder);
}
示例6: handleFindByTrialDepartmentStatusTypeShowInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<TimelineEvent> handleFindByTrialDepartmentStatusTypeShowInterval(
Long trialId, Long departmentId, Long statusId, Long typeId,
Boolean show, Timestamp from, Timestamp to) throws Exception {
Criteria timelineEventCriteria = createTimelineEventCriteria();
CriteriaUtil.applyStopOptionalIntervalCriterion(timelineEventCriteria, from, to, null, true);
if (trialId != null || departmentId != null || statusId != null) {
Criteria trialCriteria = timelineEventCriteria.createCriteria("trial", CriteriaSpecification.INNER_JOIN);
if (trialId != null) {
trialCriteria.add(Restrictions.idEq(trialId.longValue()));
}
if (departmentId != null) {
trialCriteria.add(Restrictions.eq("department.id", departmentId.longValue()));
}
if (statusId != null) {
trialCriteria.add(Restrictions.eq("status.id", statusId.longValue()));
}
}
if (typeId != null) {
timelineEventCriteria.add(Restrictions.eq("type.id", typeId.longValue()));
}
if (show != null) {
timelineEventCriteria.add(Restrictions.eq("show", show.booleanValue()));
}
return timelineEventCriteria.list();
}
示例7: handleFindByCourseSorted
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<CourseParticipationStatusEntry> handleFindByCourseSorted(
Long courseId) throws Exception {
org.hibernate.Criteria courseParticipationStatusEntryCriteria = createCourseParticipationStatusEntryCriteria();
if (courseId != null) {
courseParticipationStatusEntryCriteria.add(Restrictions.eq("course.id", courseId.longValue()));
}
Criteria staffCriteria = courseParticipationStatusEntryCriteria.createCriteria("staff", CriteriaSpecification.INNER_JOIN);
Criteria personParticularsCriteria = staffCriteria.createCriteria("personParticulars", CriteriaSpecification.INNER_JOIN);
personParticularsCriteria.addOrder(Order.asc("lastName"));
personParticularsCriteria.addOrder(Order.asc("firstName"));
return courseParticipationStatusEntryCriteria.list();
}
示例8: handleFindByTrialSorted
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<VisitScheduleItem> handleFindByTrialSorted(Long trialId, boolean sort, PSFVO psf)
throws Exception
{
Criteria visitScheduleItemCriteria = createVisitScheduleItemCriteria(null);
SubCriteriaMap criteriaMap = new SubCriteriaMap(VisitScheduleItem.class, visitScheduleItemCriteria);
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")));
// }
// if (visitId != null) {
// visitScheduleItemCriteria.add(Restrictions.or(Restrictions.eq("visit.id", visitId.longValue()),
// Restrictions.isNull("visit.id")));
// }
CriteriaUtil.applyPSFVO(criteriaMap, psf); // proband has only one probandlistentry, and listentry has only one group, but left joins
if (sort) {
visitScheduleItemCriteria.addOrder(Order.asc("trial"));
Criteria visitCriteria = visitScheduleItemCriteria.createCriteria("visit", CriteriaSpecification.LEFT_JOIN);
visitCriteria.addOrder(Order.asc("token"));
Criteria groupCriteria = visitScheduleItemCriteria.createCriteria("group", CriteriaSpecification.LEFT_JOIN);
groupCriteria.addOrder(Order.asc("token"));
visitScheduleItemCriteria.addOrder(Order.asc("token"));
}
return visitScheduleItemCriteria.list();
}
示例9: handleGetCount
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected long handleGetCount(Long trialId, Long groupId, Long visitId, Long probandId, Boolean travel)
throws Exception
{
Criteria visitScheduleItemCriteria = createVisitScheduleItemCriteria("visitScheduleItem");
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")));
}
if (visitId != null) {
visitScheduleItemCriteria.add(Restrictions.or(Restrictions.eq("visit.id", visitId.longValue()),
Restrictions.isNull("visit.id")));
}
if (probandId != null) {
Criteria trialCriteria = visitScheduleItemCriteria.createCriteria("trial");
trialCriteria.createCriteria("probandListEntries").add(Restrictions.eq("proband.id", probandId.longValue()));
Criteria groupCriteria = visitScheduleItemCriteria.createCriteria("group", CriteriaSpecification.LEFT_JOIN);
groupCriteria.createCriteria("probandListEntries", CriteriaSpecification.LEFT_JOIN).add(
Restrictions.or(Restrictions.eq("proband.id", probandId.longValue()),
Restrictions.isNull("visitScheduleItem.group")));
}
if (travel != null) {
visitScheduleItemCriteria.createCriteria("visit.type", CriteriaSpecification.LEFT_JOIN).add(
Restrictions.or(Restrictions.eq("travel", travel.booleanValue()),
Restrictions.isNull("visitScheduleItem.visit")));
}
if (probandId == null) {
return (Long) visitScheduleItemCriteria.setProjection(Projections.rowCount()).uniqueResult();
// CriteriaUtil.applyPSFVO(criteriaMap, psf); // proband has only one probandlistentry, and listentry has only one group, but left joins
// return visitScheduleItemCriteria.list();
} else {
return (Long) visitScheduleItemCriteria.setProjection(Projections.countDistinct("id")).uniqueResult();
// return CriteriaUtil.listDistinctRootPSFVO(criteriaMap, psf, this);
}
}
示例10: handleFindByDepartmentCategoryInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<InventoryStatusEntry> handleFindByDepartmentCategoryInterval(
Long departmentId, Long inventoryCategoryId, Timestamp from, Timestamp to,
Long statusTypeId, Boolean inventoryActive, Boolean bookable, Boolean hideAvailability) throws Exception {
Criteria statusEntryCriteria = createStatusEntryCriteria();
CriteriaUtil.applyStopOpenIntervalCriterion(statusEntryCriteria, from, to, null);
if (statusTypeId != null) {
statusEntryCriteria.add(Restrictions.eq("type.id", statusTypeId.longValue()));
}
if (inventoryActive != null || hideAvailability != null) {
Criteria typeCriteria = statusEntryCriteria.createCriteria("type", CriteriaSpecification.INNER_JOIN);
if (inventoryActive != null) {
typeCriteria.add(Restrictions.eq("inventoryActive", inventoryActive.booleanValue()));
}
if (hideAvailability != null) {
typeCriteria.add(Restrictions.eq("hideAvailability", hideAvailability.booleanValue()));
}
}
if (departmentId != null || inventoryCategoryId != null || bookable != null) {
Criteria inventoryCriteria = statusEntryCriteria.createCriteria("inventory", CriteriaSpecification.INNER_JOIN);
if (departmentId != null) {
inventoryCriteria.add(Restrictions.eq("department.id", departmentId.longValue()));
}
if (inventoryCategoryId != null) {
inventoryCriteria.add(Restrictions.eq("category.id", inventoryCategoryId.longValue()));
}
if (bookable != null) {
inventoryCriteria.add(Restrictions.eq("bookable", bookable.booleanValue()));
}
}
return statusEntryCriteria.list();
}
示例11: 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();
}
示例12: handleFindByDepartmentStatusStaffTrialCalendarInterval
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<DutyRosterTurn> handleFindByDepartmentStatusStaffTrialCalendarInterval(
Long trialDepartmentId, Long statusId, Long staffId, boolean unassigned, Long trialId, String calendar, Timestamp from, Timestamp to)
throws Exception {
Criteria dutyRosterCriteria = createDutyRosterTurnCriteria("dutyRosterTurn");
CriteriaUtil.applyClosedIntervalCriterion(dutyRosterCriteria, from, to, null);
Criteria trialCriteria = null;
if (trialDepartmentId != null) {
trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.LEFT_JOIN);
} else if (statusId != null || trialId != null) {
trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.INNER_JOIN);
}
if (trialDepartmentId != null || statusId != null || trialId != null) {
if (trialDepartmentId != null) {
trialCriteria.add(Restrictions.or(Restrictions.isNull("dutyRosterTurn.trial"), Restrictions.eq("department.id", trialDepartmentId.longValue())));
}
if (statusId != null) {
trialCriteria.add(Restrictions.eq("status.id", statusId.longValue()));
}
if (trialId != null) {
trialCriteria.add(Restrictions.idEq(trialId.longValue()));
}
}
if (staffId != null) {
if (unassigned) {
dutyRosterCriteria.add(Restrictions.or(Restrictions.eq("staff.id", staffId.longValue()), Restrictions.isNull("staff")));
} else {
dutyRosterCriteria.add(Restrictions.eq("staff.id", staffId.longValue()));
}
}
CategoryCriterion.apply(dutyRosterCriteria, new CategoryCriterion(calendar, "calendar", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
return dutyRosterCriteria.list();
}
示例13: 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();
}
示例14: handleFindTitles
import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
protected Collection<String> handleFindTitles(Long trialDepartmentId,
Long staffId, Long trialId, String titleInfix, 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(titleInfix, "title", MatchMode.ANYWHERE));
dutyRosterCriteria.addOrder(Order.asc("title"));
dutyRosterCriteria.setProjection(Projections.distinct(Projections.property("title")));
CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.DUTY_ROSTER_TURN_TITLE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
DefaultSettings.DUTY_ROSTER_TURN_TITLE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), dutyRosterCriteria);
return dutyRosterCriteria.list();
}
示例15: 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();
}