當前位置: 首頁>>代碼示例>>Java>>正文


Java DetachedCriteria.forClass方法代碼示例

本文整理匯總了Java中org.hibernate.criterion.DetachedCriteria.forClass方法的典型用法代碼示例。如果您正苦於以下問題:Java DetachedCriteria.forClass方法的具體用法?Java DetachedCriteria.forClass怎麽用?Java DetachedCriteria.forClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.criterion.DetachedCriteria的用法示例。


在下文中一共展示了DetachedCriteria.forClass方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createEcrfFieldStatusEntryDetachedCriteria

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
private static DetachedCriteria createEcrfFieldStatusEntryDetachedCriteria(org.hibernate.Criteria ecrfFieldStatusEntryCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,
		Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = DetachedCriteria.forClass(ECRFFieldStatusEntryImpl.class, "ecrfFieldStatusEntry1"); // IMPL!!!!
	// subQuery.setProjection(Projections.max("id"));
	if (probandListEntryId == null) {
		if (probandListEntryCriteria == null) {
			probandListEntryCriteria = ecrfFieldStatusEntryCriteria.createCriteria("listEntry", "probandListEntry0");
		}
		subQuery.add(Restrictions.eqProperty("listEntry.id", probandListEntryCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("listEntry.id", probandListEntryId.longValue()));
	}
	if (ecrfFieldId == null) {
		if (ecrfFieldCriteria == null) {
			ecrfFieldCriteria = ecrfFieldStatusEntryCriteria.createCriteria("ecrfField", "ecrfField0");
		}
		subQuery.add(Restrictions.eqProperty("ecrfField.id", ecrfFieldCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("ecrfField.id", ecrfFieldId.longValue()));
	}
	return subQuery;
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:24,代碼來源:ECRFFieldStatusEntryDaoImpl.java

示例2: deleteComponentProfileByControlId

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void deleteComponentProfileByControlId(String controlId, String name) {
	DetachedCriteria detachedCriteria = DetachedCriteria.forClass(ComponentConfig.class);
	detachedCriteria.add(Restrictions.eq("controlId", controlId));
	detachedCriteria.add(Restrictions.eq("name", name));
	Session session = this.getSessionFactory().openSession();
	try {
		org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
		List<ComponentConfig> list = criteria.list();
		if (list.size() > 0) {
			String hql = "delete " + ComponentConfigMember.class.getName()
					+ " m where m.componentConfig.id = :configId";
			session.createQuery(hql).setString("configId", list.get(0).getId()).executeUpdate();
			session.delete(list.get(0));
		}
	} finally {
		session.flush();
		session.close();
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:21,代碼來源:HibernateComponentConfigManager.java

示例3: getLast

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@Override
public QuotePE getLast(String sigle) {
	Session session = getSession();

	DetachedCriteria  maxDate = DetachedCriteria.forClass(QuotePE.class);
	maxDate.add(Restrictions.eq("symbol", sigle));
	maxDate.setProjection(Projections.max("creationDateTime"));
	
   	Criteria criteria = session.createCriteria(QuotePE.class);
   	criteria.add(Restrictions.eq("symbol", sigle));
   	criteria.add(Property.forName("creationDateTime").eq(maxDate));
   	
	QuotePE pe = (QuotePE) criteria.uniqueResult();
	session.close();
	
	return pe;
}
 
開發者ID:auTasso,項目名稱:SandBoxNGSB,代碼行數:18,代碼來源:QuoteDAOImpl.java

示例4: createEcrfFieldValueDetachedCriteria

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
private static DetachedCriteria createEcrfFieldValueDetachedCriteria(org.hibernate.Criteria ecrfFieldValueCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,
		Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = DetachedCriteria.forClass(ECRFFieldValueImpl.class, "ecrfFieldValue1"); // IMPL!!!!
	// subQuery.setProjection(Projections.max("id"));
	if (probandListEntryId == null) {
		if (probandListEntryCriteria == null) {
			probandListEntryCriteria = ecrfFieldValueCriteria.createCriteria("listEntry", "probandListEntry0");
		}
		subQuery.add(Restrictions.eqProperty("listEntry.id", probandListEntryCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("listEntry.id", probandListEntryId.longValue()));
	}
	if (ecrfFieldId == null) {
		if (ecrfFieldCriteria == null) {
			ecrfFieldCriteria = ecrfFieldValueCriteria.createCriteria("ecrfField", "ecrfField0");
		}
		subQuery.add(Restrictions.eqProperty("ecrfField.id", ecrfFieldCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("ecrfField.id", ecrfFieldId.longValue()));
	}
	return subQuery;
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:24,代碼來源:ECRFFieldValueDaoImpl.java

示例5: handleGetProbandList

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@Override
protected Collection<ProbandListEntry> handleGetProbandList(
		Long trialId, org.phoenixctms.ctsms.enumeration.ProbandListStatusLogLevel logLevel, boolean last)
				throws Exception {
	// http://stackoverflow.com/questions/1648426/hibernate-detached-queries-as-a-part-of-the-criteria-query
	// https://forum.hibernate.org/viewtopic.php?p=2317841#2317841
	org.hibernate.Criteria listEntryCriteria = createListEntryCriteria();
	boolean distinctRoot = false;
	if (trialId != null) {
		listEntryCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
	}
	if (logLevel != null) {
		org.hibernate.Criteria statusEntryCriteria;
		if (last) {
			statusEntryCriteria = listEntryCriteria.createCriteria("statusEntries", "probandListStatusEntry0", CriteriaSpecification.INNER_JOIN);
		} else {
			statusEntryCriteria = listEntryCriteria.createCriteria("statusEntries", CriteriaSpecification.INNER_JOIN);
		}
		org.hibernate.Criteria statusTypeCriteria = statusEntryCriteria.createCriteria("status", CriteriaSpecification.INNER_JOIN);
		org.hibernate.Criteria logLevelCriteria = statusTypeCriteria.createCriteria("logLevels", CriteriaSpecification.INNER_JOIN);
		logLevelCriteria.add(Restrictions.eq("logLevel", logLevel));
		if (last) {
			DetachedCriteria subQuery = DetachedCriteria.forClass(ProbandListStatusEntryImpl.class, "probandListStatusEntry1"); // IMPL!!!!
			subQuery.add(Restrictions.eqProperty("probandListStatusEntry1.listEntry", "probandListStatusEntry0.listEntry"));
			subQuery.setProjection(Projections.max("id"));
			statusEntryCriteria.add(Subqueries.propertyEq("id", subQuery));
		} else {
			// listEntryCriteria.setResultTransformer(org.hibernate.Criteria.DISTINCT_ROOT_ENTITY);
			distinctRoot = true;
		}
	}
	listEntryCriteria.addOrder(Order.asc("trial"));
	listEntryCriteria.addOrder(Order.asc("position"));
	if (distinctRoot) {
		return CriteriaUtil.listDistinctRoot(listEntryCriteria, this, "trial.id", "position");
	} else {
		return listEntryCriteria.list();
	}
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:40,代碼來源:ProbandListEntryDaoImpl.java

示例6: buildDetachedCriteria

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
public DetachedCriteria buildDetachedCriteria(Criteria criteria, Class<?> entityClass, String alias) {
	DetachedCriteria dc = null;
	if (StringUtils.isEmpty(alias)) {
		dc = DetachedCriteria.forClass(entityClass);
	} else {
		dc = DetachedCriteria.forClass(entityClass, alias);
	}
	if (criteria != null && criteria.getCriterions().size() > 0) {
		buildCriterions(criteria.getCriterions(), dc);
	}
	return dc;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:13,代碼來源:HibernateDao.java

示例7: getProductsByCreationDate

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
/**
 * Retrieve products ordered by it date of ingestion, updated.
 * The list of product is returned prior to the passed date argument.
 * Currently processed and locked products are not returned.
 *
 * @param max_date     Maximum date to retrieve products
 *                     More recent product will not be returned
 * @param max_products Maximum products to return
 * @return a scrollable list of the products
 */
@Transactional(readOnly = true)
public Iterator<Product> getProductsByCreationDate(Date max_date, int max_products)
{
   DetachedCriteria criteria = DetachedCriteria.forClass(Product.class);
   criteria.add(Restrictions.and(
         Restrictions.lt("created", max_date),
         Restrictions.and(
               Restrictions.eq("processed", true),
               Restrictions.eq("locked", false))));
   criteria.addOrder(Order.asc("created"));

   return productDao.listCriteria(criteria, 0, max_products).iterator();
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:24,代碼來源:ProductService.java

示例8: handleFindBySignup

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@Override
protected Collection<Trial> handleFindBySignup(Long departmentId, boolean ignoreSignupInquiries, PSFVO psf) throws Exception {
	org.hibernate.Criteria trialCriteria = createTrialCriteria("trial0");
	SubCriteriaMap criteriaMap = new SubCriteriaMap(Trial.class, trialCriteria);
	if (departmentId != null) {
		trialCriteria.add(Restrictions.eq("department.id", departmentId.longValue()));
	}
	org.hibernate.Criteria statusCriteria = trialCriteria.createCriteria("status", "trialStatus", CriteriaSpecification.INNER_JOIN);
	statusCriteria.add(Restrictions.eq("lockdown", false));
	DetachedCriteria subQuery = DetachedCriteria.forClass(InquiryImpl.class, "inquiry"); // IMPL!!!!
	subQuery.setProjection(Projections.rowCount());
	subQuery.add(Restrictions.eqProperty("trial.id", "trial0.id"));
	subQuery.add(Restrictions.eq("activeSignup", true));
	trialCriteria.add(
			Restrictions.or(
					Restrictions.eq("signupProbandList", true),
					Restrictions.and(
							ignoreSignupInquiries ? Subqueries.lt(0l, subQuery) : Restrictions.and(
									Restrictions.eq("signupInquiries", true),
									Subqueries.lt(0l, subQuery)
									// Restrictions.sizeGt("inquiries", 0)
									),
									Restrictions.eq("trialStatus.inquiryValueInputEnabled", true)
							)
					)
			);
	// if (probandList != null) {
	// trialCriteria.add(Restrictions.eq("signupProbandList", probandList.booleanValue()));
	// }
	// if (inquiries != null) {
	// trialCriteria.add(Restrictions.eq("signupInquiries", inquiries.booleanValue()));
	// statusCriteria.add(Restrictions.eq("inquiryValueInputEnabled", true));
	// trialCriteria.add(Restrictions.sizeGt("inquiries", 0));
	// }
	CriteriaUtil.applyPSFVO(criteriaMap, psf);
	return trialCriteria.list();
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:38,代碼來源:TrialDaoImpl.java

示例9: handleFindByMoneyTransferNoParticipation

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@Override
protected Collection<Proband> handleFindByMoneyTransferNoParticipation(Long trialId,
		PaymentMethod method, String costType, Boolean paid, boolean total,
		Boolean person, PSFVO psf)
				throws Exception {
	org.hibernate.Criteria probandCriteria = createProbandCriteria("proband0");
	if (person != null) {
		probandCriteria.add(Restrictions.eq("person", person.booleanValue()));
	}
	SubCriteriaMap criteriaMap = new SubCriteriaMap(Proband.class, probandCriteria);
	Criteria moneyTransferCriteria = criteriaMap.createCriteria("moneyTransfers");
	moneyTransferCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
	if (method != null) {
		moneyTransferCriteria.add(Restrictions.eq("method", method));
	}
	if (paid != null) {
		moneyTransferCriteria.add(Restrictions.eq("paid", paid.booleanValue()));
	}
	CategoryCriterion.apply(moneyTransferCriteria, new CategoryCriterion(costType, "costType", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
	DetachedCriteria subQuery = DetachedCriteria.forClass(ProbandListEntryImpl.class, "probandListEntry"); // IMPL!!!!
	subQuery.setProjection(Projections.rowCount());
	subQuery.add(Restrictions.eqProperty("proband.id", "proband0.id"));
	subQuery.add(Restrictions.eq("trial.id", trialId.longValue()));
	if (!total) {
		subQuery.createCriteria("lastStatus", CriteriaSpecification.INNER_JOIN).createCriteria("status", CriteriaSpecification.INNER_JOIN)
		.add(Restrictions.eq("count", true));
	}
	probandCriteria.add(Subqueries.eq(0l, subQuery));
	return CriteriaUtil.listDistinctRootPSFVO(criteriaMap, psf, this);
	// return probandCriteria.list();
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:32,代碼來源:ProbandDaoImpl.java

示例10: checkFreeDay

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
/**
 * Проверка даты на нерабочую в определенном календаре
 *
 * @param date проверяемая дата, важен месяц и день
 * @return Выходной день в этом календаре или нет
 */
public boolean checkFreeDay(Date date) {
    final DetachedCriteria criteria = DetachedCriteria.forClass(FreeDay.class);
    criteria.add(Property.forName("calendarId").eq(getId()));
    criteria.add(Property.forName("date").eq(date));
    return !(new LinkedList<>(Spring.getInstance().getHt().findByCriteria(criteria)).isEmpty());
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:13,代碼來源:QCalendar.java

示例11: buildDetachedCriteria

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
public DetachedCriteria buildDetachedCriteria(Criteria criteria,Class<?> entityClass,String alias){
	DetachedCriteria dc=null;
	if(StringUtils.isEmpty(alias)){
		dc=DetachedCriteria.forClass(entityClass);			
	}else{
		dc=DetachedCriteria.forClass(entityClass,alias);			
	}
	if(criteria!=null && criteria.getCriterions().size()>0){
		buildCriterions(criteria.getCriterions(),dc);
	}
	return dc;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:13,代碼來源:HibernateDao.java

示例12: findExcelModelById

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public ExcelModel findExcelModelById(String excelModelId) throws Exception {
	DetachedCriteria detachedCriteria = DetachedCriteria.forClass(ExcelModel.class, "m");
	detachedCriteria.add(Restrictions.eq("id", excelModelId));
	List list = findByCriteria(detachedCriteria);
	if (list.isEmpty()) {
		return null;
	} else {
		return (ExcelModel) list.get(0);
	}

}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:13,代碼來源:ExcelModelManager.java

示例13: handleFindByServiceMethodUser

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@Override
protected Collection<Permission> handleFindByServiceMethodUser(
		String serviceMethod, Long userId, Boolean profilePermissionActive,
		Boolean userPermissionProfileActive) throws Exception {
	org.hibernate.Criteria permissionCritria = createPermissionCriteria();
	if (serviceMethod != null) {
		permissionCritria.add(Restrictions.eq("serviceMethod", serviceMethod));
	}
	if (userId != null || profilePermissionActive != null || userPermissionProfileActive != null) {
		org.hibernate.Criteria profilePermissionCritria = permissionCritria.createCriteria("profilePermissions", CriteriaSpecification.LEFT_JOIN);
		if (profilePermissionActive != null) {
			profilePermissionCritria.add(Restrictions.eq("active", profilePermissionActive.booleanValue()));
		}
		if (userId != null || userPermissionProfileActive != null) {
			DetachedCriteria subQuery = DetachedCriteria.forClass(UserPermissionProfileImpl.class, "userPermissionProfile"); // IMPL!!!!
			subQuery.setProjection(Projections.projectionList().add(Projections.property("profile")));
			if (userId != null) {
				subQuery.add(Restrictions.eq("user.id", userId.longValue()));
			}
			if (userPermissionProfileActive != null) {
				subQuery.add(Restrictions.eq("active", userPermissionProfileActive.booleanValue()));
			}
			profilePermissionCritria.add(Subqueries.propertyIn("profile", subQuery));
		}
	}
	return permissionCritria.list();
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:28,代碼來源:PermissionDaoImpl.java

示例14: findExcelModelDetailByModelIdAndPrimaryKey

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public ExcelModelDetail findExcelModelDetailByModelIdAndPrimaryKey(String modelId, String tableColumn) throws Exception {
	DetachedCriteria detachedCriteria = DetachedCriteria.forClass(ExcelModelDetail.class, "m");
	detachedCriteria.add(Restrictions.eq("excelModelId", modelId));
	detachedCriteria.add(Restrictions.eq("tableColumn", tableColumn));
	List list = findByCriteria(detachedCriteria);
	if (list.isEmpty()) {
		return null;
	} else {
		return (ExcelModelDetail) list.get(0);
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:13,代碼來源:ExcelModelManager.java

示例15: loadComponentConfig

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public ComponentConfig loadComponentConfig(String controlId, String name) {
	DetachedCriteria dc = DetachedCriteria.forClass(ComponentConfig.class);
	dc.add(Restrictions.eq("name", name));
	dc.add(Restrictions.eq("controlId", controlId));
	dc.createAlias("componentConfigMembers", "m", CriteriaSpecification.LEFT_JOIN);
	dc.addOrder(Order.asc("m.order"));
	List<ComponentConfig> componentConfigs = (List<ComponentConfig>) this.query(dc);
	return componentConfigs.isEmpty() ? null : componentConfigs.get(0);
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:11,代碼來源:HibernateComponentConfigManager.java


注:本文中的org.hibernate.criterion.DetachedCriteria.forClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。