本文整理汇总了Java中org.hibernate.criterion.CriteriaSpecification类的典型用法代码示例。如果您正苦于以下问题:Java CriteriaSpecification类的具体用法?Java CriteriaSpecification怎么用?Java CriteriaSpecification使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CriteriaSpecification类属于org.hibernate.criterion包,在下文中一共展示了CriteriaSpecification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: querySqlObjects
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<Map<String, Object>> querySqlObjects(String sql, Object params, Integer currentPage,Integer rowsInPage){
Query qry = em.createNativeQuery(sql);
SQLQuery s = qry.unwrap(SQLQuery.class);
//设置参数
if(params != null){
if(params instanceof List){
List<Object> paramList = (List<Object>) params;
for(int i = 0, size = paramList.size(); i < size; i++){
qry.setParameter(i+1, paramList.get(i));
}
}else if(params instanceof Map){
Map<String, Object> paramMap = (Map<String, Object>) params;
for(String key : paramMap.keySet()){
qry.setParameter(key, paramMap.get(key));
}
}
}
if (currentPage != null && rowsInPage != null) {//判断是否有分页
// 起始对象位置
qry.setFirstResult(rowsInPage * (currentPage - 1));
// 查询对象个数
qry.setMaxResults(rowsInPage);
}
s.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);
List<Map<String, Object>> resultList=new ArrayList<Map<String, Object>>();
try {
resultList=s.list();
} catch (Exception e) {
}finally{
em.close();
}
return resultList;
}
示例2: handleFindAllSorted
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<ECRFField> handleFindAllSorted(String nameInfix, Integer limit) throws Exception {
org.hibernate.Criteria ecrfFieldCriteria = createEcrfFieldCriteria();
if (!CommonUtil.isEmptyString(nameInfix)) {
org.hibernate.Criteria trialCriteria = ecrfFieldCriteria.createCriteria("trial", "trial0", CriteriaSpecification.INNER_JOIN);
org.hibernate.Criteria ecrfCriteria = ecrfFieldCriteria.createCriteria("ecrf", "ecrf0", CriteriaSpecification.INNER_JOIN);
org.hibernate.Criteria fieldCriteria = ecrfFieldCriteria.createCriteria("field", "inputField", CriteriaSpecification.INNER_JOIN);
//fieldCriteria.add(Restrictions.eq("localized", false));
ecrfFieldCriteria.add(Restrictions.or(
(new CategoryCriterion(nameInfix, "section", MatchMode.ANYWHERE)).getRestriction(),
Restrictions.or(
(new CategoryCriterion(nameInfix, "inputField.nameL10nKey", MatchMode.ANYWHERE)).getRestriction(),
Restrictions.or(
(new CategoryCriterion(nameInfix, "ecrf0.name", MatchMode.ANYWHERE)).getRestriction(),
(new CategoryCriterion(nameInfix, "trial0.name", MatchMode.ANYWHERE)).getRestriction()
))));
}
applySortOrders(ecrfFieldCriteria);
CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.ECRF_FIELD_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
DefaultSettings.ECRF_FIELD_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), ecrfFieldCriteria);
return ecrfFieldCriteria.list();
}
示例3: applyUsedByCriterions
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
private static void applyUsedByCriterions(org.hibernate.Criteria selectionSetValueCriteria, String nameInfix, String inputFieldProperty) {
if (selectionSetValueCriteria != null) {
org.hibernate.Criteria fieldCriteria = selectionSetValueCriteria.createCriteria("field","inputField", CriteriaSpecification.INNER_JOIN);
if (!CommonUtil.isEmptyString(inputFieldProperty)) {
fieldCriteria.add(Restrictions.not(Restrictions.isEmpty(inputFieldProperty)));
}
//fieldCriteria.add(Restrictions.eq("localized", false));
if (!CommonUtil.isEmptyString(nameInfix)) {
selectionSetValueCriteria.add(Restrictions.or(
(new CategoryCriterion(nameInfix, "inputField.nameL10nKey", MatchMode.ANYWHERE)).getRestriction(),
(new CategoryCriterion(nameInfix, "nameL10nKey", MatchMode.ANYWHERE)).getRestriction()
));
}
}
}
示例4: handleFindAllSorted
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<Inquiry> handleFindAllSorted(String nameInfix, Integer limit) throws Exception {
org.hibernate.Criteria inquiryCriteria = createInquiryCriteria();
if (!CommonUtil.isEmptyString(nameInfix)) {
org.hibernate.Criteria trialCriteria = inquiryCriteria.createCriteria("trial", "trial0", CriteriaSpecification.INNER_JOIN);
org.hibernate.Criteria fieldCriteria = inquiryCriteria.createCriteria("field", "inputField", CriteriaSpecification.INNER_JOIN);
//fieldCriteria.add(Restrictions.eq("localized", false));
inquiryCriteria.add(Restrictions.or(
(new CategoryCriterion(nameInfix, "category", MatchMode.ANYWHERE)).getRestriction(),
Restrictions.or(
(new CategoryCriterion(nameInfix, "inputField.nameL10nKey", MatchMode.ANYWHERE)).getRestriction(),
(new CategoryCriterion(nameInfix, "trial0.name", MatchMode.ANYWHERE)).getRestriction()
)));
}
applySortOrders(inquiryCriteria);
CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INQUIRY_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
DefaultSettings.INQUIRY_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), inquiryCriteria);
return inquiryCriteria.list();
}
示例5: handleFindByParticipantsActiveSorted
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<Inquiry> handleFindByParticipantsActiveSorted(Long trialId, Boolean active, Boolean activeSignup) throws Exception {
org.hibernate.Criteria inquiryCriteria = createInquiryCriteria();
if (active != null) {
inquiryCriteria.add(Restrictions.eq("active", active.booleanValue()));
}
if (activeSignup != null) {
inquiryCriteria.add(Restrictions.eq("activeSignup", activeSignup.booleanValue()));
}
if (trialId != null) {
inquiryCriteria.createCriteria("inquiryValues", CriteriaSpecification.INNER_JOIN).createCriteria("proband", CriteriaSpecification.INNER_JOIN)
.createCriteria("trialParticipations", CriteriaSpecification.INNER_JOIN).add(Restrictions.eq("trial.id", trialId.longValue()));
}
applySortOrders(inquiryCriteria);
// inquiryCriteria.setResultTransformer(org.hibernate.Criteria.DISTINCT_ROOT_ENTITY);
// return inquiryCriteria.list();
return CriteriaUtil.listDistinctRoot(inquiryCriteria, this, "trial.id", "category", "position");
}
示例6: handleFindByTrialActiveExcelProbandSorted
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<Inquiry> handleFindByTrialActiveExcelProbandSorted(Long trialId, Boolean active, Boolean activeSignup, Boolean excel, Long probandId) throws Exception {
org.hibernate.Criteria inquiryCriteria = createInquiryCriteria();
if (trialId != null) {
inquiryCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
}
if (active != null) {
inquiryCriteria.add(Restrictions.eq("active", active.booleanValue()));
}
if (activeSignup != null) {
inquiryCriteria.add(Restrictions.eq("activeSignup", activeSignup.booleanValue()));
}
if (excel != null) {
inquiryCriteria.add(Restrictions.or(Restrictions.eq("excelValue", excel.booleanValue()),
Restrictions.eq("excelDate", excel.booleanValue())));
}
if (probandId != null) {
inquiryCriteria.createCriteria("inquiryValues", CriteriaSpecification.INNER_JOIN).add(Restrictions.eq("proband.id", probandId.longValue()));
}
applySortOrders(inquiryCriteria);
// inquiryCriteria.setResultTransformer(org.hibernate.Criteria.DISTINCT_ROOT_ENTITY);
// return inquiryCriteria.list();
return CriteriaUtil.listDistinctRoot(inquiryCriteria, this, "trial.id", "category", "position");
}
示例7: handleGetTrialGroupProbandCount
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected long handleGetTrialGroupProbandCount(
Long trialId, Long probandGroupId, Long probandId, boolean total) throws Exception {
org.hibernate.Criteria listEntryCriteria = createListEntryCriteria();
if (trialId != null) {
listEntryCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
}
if (probandGroupId != null) {
listEntryCriteria.add(Restrictions.eq("group.id", probandGroupId.longValue()));
}
if (probandId != null) {
listEntryCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
}
if (!total) {
listEntryCriteria.createCriteria("lastStatus", CriteriaSpecification.INNER_JOIN).createCriteria("status", CriteriaSpecification.INNER_JOIN)
.add(Restrictions.eq("count", true));
// istEntryCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
}
return (Long) listEntryCriteria.setProjection(Projections.rowCount()).uniqueResult();
}
示例8: handleFindByListEntryJs
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<Map> handleFindByListEntryJs(Long probandListEntryId, boolean sort, Boolean js, PSFVO psf) throws Exception {
org.hibernate.Criteria listEntryTagCriteria = createProbandListEntryTagCriteria(probandListEntryId);
// if (active != null) {
// ecrfFieldCriteria.add(Restrictions.eq("active", active.booleanValue()));
// }
if (js != null) {
if (js) {
listEntryTagCriteria.add(Restrictions.and(Restrictions.ne("jsVariableName", ""), Restrictions.isNotNull("jsVariableName")));
} else {
listEntryTagCriteria.add(Restrictions.or(Restrictions.eq("jsVariableName", ""), Restrictions.isNull("jsVariableName")));
}
}
if (psf != null) {
SubCriteriaMap criteriaMap = new SubCriteriaMap(ProbandListEntryTag.class, listEntryTagCriteria);
// clear sort and filters?
CriteriaUtil.applyPSFVO(criteriaMap, psf);
}
if (sort) {
applySortOrders(listEntryTagCriteria);
}
listEntryTagCriteria.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);
return listEntryTagCriteria.list();
}
示例9: applyAspSubstanceNameCriterions
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
private static void applyAspSubstanceNameCriterions(org.hibernate.Criteria aspSubstanceCriteria, String nameInfix) {
String revision = Settings.getString(SettingCodes.ASP_REVISION, Bundle.SETTINGS, DefaultSettings.ASP_REVISION);
ArrayList<CategoryCriterion> criterions = new ArrayList<CategoryCriterion>();
criterions.add(new CategoryCriterion(nameInfix, "name", MatchMode.ANYWHERE));
if (MATCH_ASP_NAME || MATCH_ASP_REGISTRATION_NUMBER || MATCH_ATC_CODE_CODE) {
org.hibernate.Criteria aspsCriteria = aspSubstanceCriteria.createCriteria("asps", "asps0", CriteriaSpecification.LEFT_JOIN);
if (MATCH_ASP_NAME) {
criterions.add(new CategoryCriterion(nameInfix, "asps0.name", MatchMode.ANYWHERE));
}
if (MATCH_ASP_REGISTRATION_NUMBER) {
criterions.add(new CategoryCriterion(nameInfix, "asps0.registrationNumber", MatchMode.EXACT));
}
aspsCriteria.add(Restrictions.eq("revision", revision));
if (MATCH_ATC_CODE_CODE) {
org.hibernate.Criteria atcCodesCriteria = aspsCriteria.createCriteria("atcCodes", "atcCodes0", CriteriaSpecification.LEFT_JOIN);
atcCodesCriteria.add(Restrictions.eq("revision", revision));
criterions.add(new CategoryCriterion(nameInfix, "atcCodes0.code", MatchMode.EXACT));
}
}
CategoryCriterion.applyOr(aspSubstanceCriteria, criterions);
aspSubstanceCriteria.add(Restrictions.eq("revision", revision));
}
示例10: handleFindEcrfJournal
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<JournalEntry> handleFindEcrfJournal(Long trailId) throws Exception {
org.hibernate.Criteria journalCriteria = createJournalEntryCriteria(null);
journalCriteria.add(Restrictions.or(
Restrictions.eq("systemMessage", false),
Restrictions.or(Restrictions.and(Restrictions.eq("systemMessage", true), Restrictions.eq("systemMessageModule", JournalModule.TRIAL_JOURNAL)),
Restrictions.and(Restrictions.eq("systemMessage", true), Restrictions.eq("systemMessageModule", JournalModule.INPUT_FIELD_JOURNAL))) )
);
journalCriteria.createCriteria("category", CriteriaSpecification.LEFT_JOIN).add(Restrictions.or(
Restrictions.or(Restrictions.eq("module", JournalModule.TRIAL_JOURNAL),Restrictions.eq("module", JournalModule.INPUT_FIELD_JOURNAL)), Restrictions.isNull("module")));
journalCriteria.createCriteria("inputField", CriteriaSpecification.LEFT_JOIN).createCriteria("ecrfFields", "trialEcrfField", CriteriaSpecification.LEFT_JOIN);
journalCriteria.add(Restrictions.or(Restrictions.eq("trial.id", trailId.longValue()),
Restrictions.eq("trialEcrfField.trial.id", trailId.longValue())));
journalCriteria.addOrder(Order.asc("id"));
return CriteriaUtil.listDistinctRoot(journalCriteria, this);
//journalCriteria.setResultTransformer(org.hibernate.Criteria.DISTINCT_ROOT_ENTITY); //loaded in memory anyway.
//return journalCriteria.list();
}
示例11: handleFindMaintenanceInterval
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的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);
}
示例12: handleFindByStaffCourseRelevantForCourseAppointments
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<CourseParticipationStatusEntry> handleFindByStaffCourseRelevantForCourseAppointments(Long staffId, Long courseId, Boolean isRelevantForCourseAppointments)
throws Exception
{
org.hibernate.Criteria courseParticipationStatusEntryCriteria = createCourseParticipationStatusEntryCriteria();
if (staffId != null) {
courseParticipationStatusEntryCriteria.add(Restrictions.eq("staff.id", staffId.longValue()));
}
if (courseId != null) {
courseParticipationStatusEntryCriteria.add(Restrictions.eq("course.id", courseId.longValue()));
}
if (isRelevantForCourseAppointments != null) {
courseParticipationStatusEntryCriteria.createCriteria("status", CriteriaSpecification.INNER_JOIN).add(
Restrictions.eq("relevantForCourseAppointments", isRelevantForCourseAppointments.booleanValue()));
}
return courseParticipationStatusEntryCriteria.list();
}
示例13: applyAspNameCriterions
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
private static void applyAspNameCriterions(org.hibernate.Criteria aspCriteria, String nameInfix) {
String revision = Settings.getString(SettingCodes.ASP_REVISION, Bundle.SETTINGS, DefaultSettings.ASP_REVISION);
ArrayList<CategoryCriterion> criterions = new ArrayList<CategoryCriterion>();
criterions.add(new CategoryCriterion(nameInfix, "name", MatchMode.ANYWHERE));
if (MATCH_REGISTRATION_NUMBER) {
criterions.add(new CategoryCriterion(nameInfix, "registrationNumber", MatchMode.EXACT));
}
if (MATCH_SUBSTANCE_NAME) {
org.hibernate.Criteria substancesCriteria = aspCriteria.createCriteria("substances", "substances0", CriteriaSpecification.LEFT_JOIN);
substancesCriteria.add(Restrictions.eq("revision", revision));
criterions.add(new CategoryCriterion(nameInfix, "substances0.name", MatchMode.ANYWHERE));
}
if (MATCH_ATC_CODE_CODE) {
org.hibernate.Criteria atcCodesCriteria = aspCriteria.createCriteria("atcCodes", "atcCodes0", CriteriaSpecification.LEFT_JOIN);
atcCodesCriteria.add(Restrictions.eq("revision", revision));
criterions.add(new CategoryCriterion(nameInfix, "atcCodes0.code", MatchMode.EXACT));
}
CategoryCriterion.applyOr(aspCriteria, criterions);
aspCriteria.add(Restrictions.eq("revision", revision));
}
示例14: handleGetEcrfFieldMaxSelectionSetValueCount
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected long handleGetEcrfFieldMaxSelectionSetValueCount(Long trialId) throws Exception {
org.hibernate.Criteria inputFieldCriteria = createInputFieldCriteria();
inputFieldCriteria.add(
Restrictions.in("fieldType", SELECT_FIELD_TYPES)); // no AUTOCOMPLETE!
org.hibernate.Criteria ecrfFieldCriteria = inputFieldCriteria.createCriteria("ecrfFields", "ecrfFields0", CriteriaSpecification.INNER_JOIN);
ecrfFieldCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
org.hibernate.Criteria selectionSetValueCriteria = inputFieldCriteria.createCriteria("selectionSetValues","inputFieldSelectionSetValues", CriteriaSpecification.INNER_JOIN);
inputFieldCriteria.setProjection(Projections.projectionList()
.add(Projections.groupProperty("ecrfFields0.id"))
.add(Projections.alias(Projections.count("inputFieldSelectionSetValues.id"),"selectionSetValuesCount")));
inputFieldCriteria.addOrder(Order.desc("selectionSetValuesCount"));
inputFieldCriteria.setMaxResults(1);
long maxSelectionSetValues = 0l;
try {
maxSelectionSetValues = (Long) ((Object[]) inputFieldCriteria.list().iterator().next())[1];
} catch (Exception e) {
}
return maxSelectionSetValues;
}
示例15: handleFindByTrialExcelEcrfProbandSorted
import org.hibernate.criterion.CriteriaSpecification; //导入依赖的package包/类
@Override
protected Collection<ProbandListEntryTag> handleFindByTrialExcelEcrfProbandSorted(Long trialId, Boolean excel, Boolean ecrf, Long probandId) throws Exception {
org.hibernate.Criteria listEntryTagCriteria = createListEntryTagCriteria();
if (trialId != null) {
listEntryTagCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
}
if (excel != null) {
listEntryTagCriteria.add(Restrictions.or(Restrictions.eq("excelValue", excel.booleanValue()),
Restrictions.eq("excelDate", excel.booleanValue())));
}
if (ecrf != null) {
listEntryTagCriteria.add(Restrictions.eq("ecrfValue", ecrf.booleanValue()));
}
if (probandId != null) {
listEntryTagCriteria.createCriteria("tagValues", CriteriaSpecification.INNER_JOIN).createCriteria("listEntry", CriteriaSpecification.INNER_JOIN)
.add(Restrictions.eq("proband.id", probandId.longValue()));
}
applySortOrders(listEntryTagCriteria);
// listEntryTagCriteria.setResultTransformer(org.hibernate.Criteria.DISTINCT_ROOT_ENTITY);
// return listEntryTagCriteria.list();
return CriteriaUtil.listDistinctRoot(listEntryTagCriteria, this, "trial.id", "position");
}