当前位置: 首页>>代码示例>>Java>>正文


Java ProjectionList类代码示例

本文整理汇总了Java中org.hibernate.criterion.ProjectionList的典型用法代码示例。如果您正苦于以下问题:Java ProjectionList类的具体用法?Java ProjectionList怎么用?Java ProjectionList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProjectionList类属于org.hibernate.criterion包,在下文中一共展示了ProjectionList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAppsOfDropMarket

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
@Override
public List<App> getAppsOfDropMarket(Session session, String marketName, Integer currentPage, Integer pageSize) {
    ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("pkname"));
    proList.add(Projections.property("signatureSha1"));
    Criteria cri = session.createCriteria(App.class);
    cri.setProjection(proList);
    cri.setMaxResults(pageSize);
    cri.setFirstResult(HibernateHelper.firstResult(currentPage, pageSize));
    List<Object[]> list = HibernateHelper.list(cri);
    List<App> apps = null;
    if (list != null) {
        apps = new ArrayList<App>(list.size());
        for (Object[] obj : list) {
            App e = new App();
            e.setPkname((String) obj[0]);
            e.setSignatureSha1((String) obj[1]);
            apps.add(e);
        }
        list.clear();
    }
    return apps;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:24,代码来源:AppDaoImpl.java

示例2: prepareItemQuery

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
@Override
public void prepareItemQuery(ItemSerializerState state)
{
	final DetachedCriteria criteria = state.getItemQuery();
	final ProjectionList projection = state.getItemProjection();

	if( state.hasCategory(ItemSerializerService.CATEGORY_BASIC) )
	{
		projection.add(Projections.property("name.id"), NAME_ALIAS);
		projection.add(Projections.property("description.id"), DESC_ALIAS);
	}

	if( state.hasCategory(ItemSerializerService.CATEGORY_METADATA) )
	{
		criteria.createAlias("itemXml", "itemXml");
		projection.add(Projections.property("itemXml.xml"), METADATA_ALIAS);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:BasicItemSerializerProvider.java

示例3: listMarketRank

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
@Override
public List<Market> listMarketRank() {
    ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("marketName"));
    proList.add(Projections.property("rank"));
    Criteria cri = getSession().createCriteria(Market.class);
    cri.setProjection(proList);
    List<Object[]> list = HibernateHelper.list(cri);
    List<Market> markets = null;
    if (list != null && !list.isEmpty()) {
        markets = new ArrayList<Market>(list.size());
        for (Object[] obj : list) {
            Market m = new Market();
            m.setMarketName((String) obj[0]);
            m.setRank((Integer) obj[1]);
            markets.add(m);
        }
    }
    return markets;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:21,代码来源:MarketDaoImpl.java

示例4: listDistinctRoot

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
public static List listDistinctRoot(Criteria criteria,Object dao,String... fields) throws Exception {
	if (dao != null && criteria != null) {
		criteria.setProjection(null);
		criteria.setResultTransformer(Criteria.ROOT_ENTITY);
		Method loadMethod = CoreUtil.getDaoLoadMethod(dao);
		ProjectionList projectionList = Projections.projectionList().add(Projections.id());
		boolean cast = false;
		if (fields != null && fields.length > 0) {
			for (int i = 0; i< fields.length; i++) {
				projectionList.add(Projections.property(fields[i]));
			}
			cast = true;
		}
		List items = criteria.setProjection(Projections.distinct(projectionList)).list();
		Iterator it = items.iterator();
		ArrayList result = new ArrayList(items.size());
		while (it.hasNext()) {
			result.add(loadMethod.invoke(dao, cast ? ((Object[]) it.next())[0] : it.next()));
		}
		return result;
	}
	return null;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:24,代码来源:CriteriaUtil.java

示例5: createEcrfFieldStatusEntryDetachedCriteriaMaxId

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
private static DetachedCriteria createEcrfFieldStatusEntryDetachedCriteriaMaxId(org.hibernate.Criteria ecrfFieldStatusEntryCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,
		ECRFFieldStatusQueue queue, Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = createEcrfFieldStatusEntryDetachedCriteria(ecrfFieldStatusEntryCriteria, ecrfFieldCriteria, probandListEntryCriteria, probandListEntryId,
			ecrfFieldId);
	if (queue != null) {
		subQuery.add(Restrictions.eq("queue", queue));
		subQuery.setProjection(Projections.max("id"));
	} else {
		ProjectionList proj = Projections.projectionList();
		proj.add(Projections.sqlGroupProjection(
				"max({alias}.id) as maxId",
				"{alias}.queue",
				new String[] { "maxId" },
				new org.hibernate.type.Type[] { Hibernate.LONG }));
		subQuery.setProjection(proj);
	}

	return subQuery;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:21,代码来源:ECRFFieldStatusEntryDaoImpl.java

示例6: calculateClientSurveyScore

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
public List<ClientSurveyScore> calculateClientSurveyScore(Integer startIndex,Integer maxItems,String projectGroupCode) {
	DetachedCriteria criteria = DetachedCriteria.forClass(SectionScoreEntity.class);
	criteria.createAlias("surveyEntity", "surveyEntity");
	
	ProjectionList projectionList = Projections.projectionList();
	projectionList.add(Projections.sum("sectionScore"),"surveyScore");
	projectionList.add(Projections.property("surveyEntity.id"),"surveyId");
	projectionList.add(Projections.property("clientId"),"clientId");
	projectionList.add(Projections.property("surveyEntity.projectGroupCode"),"projectGroupCode");
	projectionList.add(Projections.property("surveyEntity.createdAt"),"surveyDate");
	projectionList.add(Projections.groupProperty("surveyEntity.id"));
	projectionList.add(Projections.groupProperty("clientId"));
	projectionList.add(Projections.groupProperty("surveyEntity.tagValue"),"surveyTagValue");
	criteria.setProjection(projectionList);
	criteria.add(Restrictions.eq("surveyEntity.projectGroupCode",projectGroupCode));
	criteria.setResultTransformer(Transformers.aliasToBean(ClientSurveyScore.class));
	return (List<ClientSurveyScore>) findByCriteria(criteria,startIndex,maxItems);
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:19,代码来源:SectionScoreDaoImplV3.java

示例7: findCurrentEncounterByPatientId

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
public Encounter findCurrentEncounterByPatientId(int patientId) throws Exception {
  Patient patient = findPatientById(patientId);
  Session session = this.getSession();
  Criteria crit = session.createCriteria(Encounter.class);
  crit.add(Restrictions.eq("patient", patient));
  ProjectionList proj = Projections.projectionList();
  proj = proj.add(Projections.max("id"));
  crit = crit.setProjection(proj);
  Integer id = (Integer)crit.uniqueResult();
  crit = session.createCriteria(Encounter.class);
  crit.add(Restrictions.eq("id", id));
  Encounter encounter = (Encounter)crit.uniqueResult();
  if (encounter != null) {
    encounter.getSupp().setEncounterQuestionList(getEncounterQuestionsByEncounter(encounter.getId()));
    patient.getHist().setPatientMedicationList(getPatientMedicationsByPatient(patient.getId()));
    encounter.setDxCodes(getDxCodes(encounter.getId()));
    encounter.setTxCodes(getTxCodes(encounter.getId()));
  } 
  return encounter;
}
 
开发者ID:wdeanmedical,项目名称:ehr,代码行数:21,代码来源:PatientDAO.java

示例8: findByCriteriaRestricted

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
/**
 * Gets the results, that match a variable number of passed criterions, but return a
 * stripped version of the entities, where only the fieldNames in <code>restrictFieldNames</code>
 * have their actual values set.
 *
 * You can call this with <code>restrictFieldNames</code> = <code>null</code> to get the full
 * entities back.
 *
 * You can call this method without criterion arguments to find all entities (stripped down to
 * the <code>restrictFieldNames</code>).
 *
 * If this is called as <code>findByCriteriaRestricted(null)</code> the return value equals the
 * return value of <code>findByCriteria()</code>.
 *
 * @param restrictFieldNames
 * @param criterion
 * @return
 * @throws HibernateException
 */
@SuppressWarnings("unchecked")
public List<E> findByCriteriaRestricted(List<String> restrictFieldNames, Criterion... criterion) throws HibernateException {
	LOG.trace("Finding instances of " + entityClass.getSimpleName()
			+ " based on " + criterion.length + " criteria");

	Criteria criteria = createDistinctRootEntityCriteria(criterion);

	if (restrictFieldNames != null){
		ProjectionList projectionList = Projections.projectionList();
		for (String restrictFieldName : restrictFieldNames) {
			PropertyProjection pp = Projections.property(restrictFieldName);
			projectionList.add(pp, restrictFieldName);
		}
		criteria.setProjection(projectionList);
		criteria.setResultTransformer(
			Transformers.aliasToBean(entityClass)
		);
	}

	return criteria.list();
}
 
开发者ID:terrestris,项目名称:shogun2,代码行数:41,代码来源:GenericHibernateDao.java

示例9: sum

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<?> sum(Class<?> clz, String groupBy, Sort order, CriteriaConfiguration... configs) {

	Criteria criteria = createCriteria(clz);

	for (CriteriaConfiguration c : configs) {
		c.configure(criteria);
	}

	criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
	
	ProjectionList projectionList = Projections.projectionList();
	projectionList.add(Projections.groupProperty(groupBy));
	projectionList.add(Projections.sum(groupBy), "sum");
	criteria.setProjection(projectionList);
	
	if(order.equals(Sort.DESC)) {
		criteria.addOrder(Order.desc("sum"));
	} else {
		criteria.addOrder(Order.asc("sum"));
	}
	
	return criteria.list();
}
 
开发者ID:ludup,项目名称:hypersocket-framework,代码行数:26,代码来源:AbstractRepositoryImpl.java

示例10: createAliasedProjectionList

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
/**
 * @deprecated This method does not work well due to Hibernate bug HHH-817, nor does
 *             AliasToBeanResultTransformer handle multi-level property values.
 *             Therefore it should not be used.
 *
 * @param propertyNames
 * @param alias
 * @param aliasPath
 * @param domainClass
 * @return
 *
 * @see http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
 */
@Deprecated
public static Projection createAliasedProjectionList(final String[] propertyNames,
		final String alias, final String aliasPath, final Class<?> domainClass)
{
	final ProjectionList projectionList = Projections.projectionList();
	for (final String propertyName : propertyNames)
	{
		final Field field = ReflectionUtils.findField(domainClass, propertyName);
		if (!hasAssociationAnnotation(field))
		{
			final String aliasedProperty = alias + "." + propertyName;
			projectionList
					.add(Projections.property(aliasedProperty), aliasedProperty);
		}
	}
	return projectionList;
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:31,代码来源:HibernateUtil.java

示例11: getJobDateRange

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private Map getJobDateRange(Session session, boolean ignoreTestAccounts) {
	//Get min and max values of dates
	Criteria rangeCriteria = session.createCriteria(JobLogEntry.class);
	testAccountFilter.addCriteriaForTestAccounts(session, ignoreTestAccounts, rangeCriteria);
	ProjectionList projections = Projections.projectionList();
	projections.add(Projections.min(JobLogContainer.START_TIME), "min");
	projections.add(Projections.max(JobLogContainer.START_TIME), "max");
	rangeCriteria.setProjection(projections);
	rangeCriteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

	@SuppressWarnings("unchecked")
	List<Map> rangeList = rangeCriteria.list();

	return rangeList.get(0);
}
 
开发者ID:chipster,项目名称:chipster,代码行数:17,代码来源:StatDataSource.java

示例12: getIndividualUIDResult

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
private UIDResult getIndividualUIDResult(String sopInstanceUID)
{
	UIDResult uidResult = null;
	DetachedCriteria criteria = DetachedCriteria.forClass(GeneralImage.class);
	ProjectionList projectionList = Projections.projectionList();
	projectionList.add(Projections.property("submissionDate"));
	projectionList.add(Projections.property("md5Digest"));
	criteria.setProjection(projectionList);
   	criteria.add(Restrictions.eq("SOPInstanceUID",sopInstanceUID));
   	List result = getHibernateTemplate().findByCriteria(criteria);
   	//Since SOPInstanceUID is unique, the result either 0 or 1
   	if (result != null && result.size() > 0)
   	{
   		Object[] o = (Object[])result.get(0);
   		Date submissionDate = (Date)o[0];
   		long datetime = submissionDate.getTime();
   		String mdDigest = (String)o[1] == null ? "" : (String)o[1];
   		uidResult = UIDResult.PRESENT(datetime, mdDigest);
   	}
   	if (result == null || result.size() == 0)
   	{
   		uidResult = UIDResult.MISSING();
   	}

	return uidResult;
}
 
开发者ID:NCIP,项目名称:national-biomedical-image-archive,代码行数:27,代码来源:DicomSOPInstanceUIDQuery.java

示例13: getSharedListResult

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
private List<Object[]> getSharedListResult (List<String> seriesUids)
{
	List<Object[]> results = new ArrayList<Object[]>();

	if (seriesUids != null && seriesUids.size() != 0){
        DetachedCriteria criteria = DetachedCriteria.forClass(CustomSeriesListAttribute.class);
		ProjectionList projectionList = Projections.projectionList();

		projectionList.add(Projections.property("csl.userName"));
		projectionList.add(Projections.property("csl.name"));
		projectionList.add(Projections.property("seriesInstanceUid"));

		criteria.setProjection(Projections.distinct(projectionList));

		criteria.createAlias("parent", "csl");

		criteria.add(Restrictions.in("seriesInstanceUid", seriesUids));

		results = getHibernateTemplate().findByCriteria(criteria);
	}

	return results;
}
 
开发者ID:NCIP,项目名称:national-biomedical-image-archive,代码行数:24,代码来源:CustomSeriesListDAOImpl.java

示例14: addWhere

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
@Override
public void addWhere(ItemSerializerState state)
{
	ProjectionList projections = state.getItemProjection();
	DetachedCriteria criteria = state.getItemQuery();
	criteria.add(Restrictions.eq("uuid", uuid));
	criteria.addOrder(Order.asc(PROPERTY_VERSION));
	projections.add(Projections.property(PROPERTY_VERSION), ALIAS_VERSION);
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:AllVersionsWhereClause.java

示例15: addWhere

import org.hibernate.criterion.ProjectionList; //导入依赖的package包/类
@Override
public void addWhere(ItemSerializerState state)
{
	DetachedCriteria criteria = state.getItemQuery();
	ProjectionList projections = state.getItemProjection();
	criteria.add(Restrictions.eq("uuid", uuid));
	if( live )
	{
		criteria.add(Restrictions.eq("status", ItemStatus.LIVE.name()));
	}
	criteria.addOrder(Order.desc(PROPERTY_VERSION));
	projections.add(Projections.property(PROPERTY_VERSION), ALIAS_VERSION);
	state.setMaxResults(1);
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:LatestVersionWhereClause.java


注:本文中的org.hibernate.criterion.ProjectionList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。