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


Java ResultTransformer类代码示例

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


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

示例1: getResultList

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
   protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException {
	// meant to handle dynamic instantiation queries...(Copy from QueryLoader)
	HolderInstantiator holderInstantiator = HolderInstantiator.getHolderInstantiator(
			null,
			resultTransformer,
			getReturnAliasesForTransformer()
	);
	if ( holderInstantiator.isRequired() ) {
		for ( int i = 0; i < results.size(); i++ ) {
			Object[] row = ( Object[] ) results.get( i );
			Object result = holderInstantiator.instantiate(row);
			results.set( i, result );
		}

		return resultTransformer.transformList(results);
	}
	else {
		return results;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:CustomLoader.java

示例2: getResultList

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException {
	// meant to handle dynamic instantiation queries...
	HolderInstantiator holderInstantiator = buildHolderInstantiator( resultTransformer );
	if ( holderInstantiator.isRequired() ) {
		for ( int i = 0; i < results.size(); i++ ) {
			Object[] row = ( Object[] ) results.get( i );
			Object result = holderInstantiator.instantiate(row);
			results.set( i, result );
		}

		if ( !hasSelectNew() && resultTransformer != null ) {
			return resultTransformer.transformList(results);
		}
		else {
			return results;
		}
	}
	else {
		return results;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:QueryLoader.java

示例3: executeLoad

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
protected List executeLoad(
		SessionImplementor session,
		QueryParameters queryParameters,
		LoadQueryDetails loadQueryDetails,
		boolean returnProxies,
		ResultTransformer forcedResultTransformer) throws SQLException {
	final List<AfterLoadAction> afterLoadActions = new ArrayList<AfterLoadAction>();
	return executeLoad(
			session,
			queryParameters,
			loadQueryDetails,
			returnProxies,
			forcedResultTransformer,
			afterLoadActions
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:AbstractLoadPlanBasedLoader.java

示例4: getResultColumnOrRow

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)
throws SQLException, HibernateException {
	final Object[] result;
	final String[] aliases;
	if ( translator.hasProjection() ) {
		Type[] types = translator.getProjectedTypes();
		result = new Object[types.length];
		String[] columnAliases = translator.getProjectedColumnAliases();
		for ( int i=0; i<result.length; i++ ) {
			result[i] = types[i].nullSafeGet(rs, columnAliases[i], session, null);
		}
		aliases = translator.getProjectedAliases();
	}
	else {
		result = row;
		aliases = userAliases;
	}
	return translator.getRootCriteria().getResultTransformer()
			.transformTuple(result, aliases);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:CriteriaLoader.java

示例5: getResultList

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException {
	// meant to handle dynamic instantiation queries...(Copy from QueryLoader)
	HolderInstantiator holderInstantiator = HolderInstantiator.getHolderInstantiator(
			null,
			resultTransformer,
			getReturnAliasesForTransformer()
	);
	if ( holderInstantiator.isRequired() ) {
		for ( int i = 0; i < results.size(); i++ ) {
			Object[] row = ( Object[] ) results.get( i );
			Object result = holderInstantiator.instantiate(row);
			results.set( i, result );
		}
		
		return resultTransformer.transformList(results);
	}
	else {
		return results;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:CustomLoader.java

示例6: getResultList

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException {
	// meant to handle dynamic instantiation queries...
	HolderInstantiator holderInstantiator = HolderInstantiator.getHolderInstantiator(selectNewTransformer, resultTransformer, queryReturnAliases);
	if ( holderInstantiator.isRequired() ) {
		for ( int i = 0; i < results.size(); i++ ) {
			Object[] row = ( Object[] ) results.get( i );
			Object result = holderInstantiator.instantiate(row);
			results.set( i, result );
		}

		if(!hasSelectNew() && resultTransformer!=null) {
			return resultTransformer.transformList(results);
		} else {
			return results;
		}
	} else {
		return results;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:QueryLoader.java

示例7: getResultColumnOrRow

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)
		throws SQLException, HibernateException {
	row = toResultRow( row );
	if ( hasScalars ) {
		String[][] scalarColumns = getColumnNames();
		int queryCols = returnTypes.length;
		if ( holderClass == null && queryCols == 1 ) {
			return returnTypes[0].nullSafeGet( rs, scalarColumns[0], session, null );
		}
		else {
			row = new Object[queryCols];
			for ( int i = 0; i < queryCols; i++ )
				row[i] = returnTypes[i].nullSafeGet( rs, scalarColumns[i], session, null );
			return row;
		}
	}
	else if ( holderClass == null ) {
		return row.length == 1 ? row[0] : row;
	}
	else {
		return row;
	}

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:25,代码来源:QueryTranslatorImpl.java

示例8: transformToGisFeatureDistance

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
/**
 * Transform to bean. See bug
 * http://opensource.atlassian.com/projects/hibernate/browse/HHH-2463
 * 
 * @param aliasList
 *                the alias list
 * @param resultList
 *                the result list
 * 
 * @return the list of GisFeatureDistance
 */
//TODO tests zip test
public static List<GisFeatureDistance> transformToGisFeatureDistance(String aliasList[], List<?> resultList, Map<Long, Set<String>> featureIdToZipCodesMap,Class clazz) {
	List<GisFeatureDistance> results = new ArrayList<GisFeatureDistance>();
	if (aliasList != null && !resultList.isEmpty()) {
		ResultTransformer tr = new AliasToBeanResultTransformer(GisFeatureDistance.class);
		Iterator<?> it = resultList.iterator();
		Object[] obj;
		GisFeatureDistance gisFeatureDistance;
		while (it.hasNext()) {
			obj = (Object[]) it.next();
			gisFeatureDistance = (GisFeatureDistance) tr.transformTuple(obj, aliasList);
			int indexInList = results.indexOf(gisFeatureDistance);
			if (indexInList == -1) {
			    gisFeatureDistanceFactory.updateFields(gisFeatureDistance,clazz);
				results.add(gisFeatureDistance);
				if (featureIdToZipCodesMap != null){
				    gisFeatureDistance.setZipCodes(featureIdToZipCodesMap.get(gisFeatureDistance.getId()));
				}
			}
		}
	}

	return results;
}
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:36,代码来源:ResultTransformerUtil.java

示例9: getAlarmDefResultTransformer

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
private static ResultTransformer getAlarmDefResultTransformer() {
  return new ResultTransformer() {
    private static final long serialVersionUID = -3052468375925339521L;

    @Override
    public Object transformTuple(final Object[] tuple, final String[] aliases) {
      for (int i = 0, length = aliases.length; i < length; i++) {
        aliases[i] = aliases[i].toUpperCase();
      }
      return AliasToEntityMapResultTransformer
          .INSTANCE
          .transformTuple(tuple, aliases);
    }

    @Override
    public List transformList(final List collection) {
      return AliasToEntityMapResultTransformer
          .INSTANCE
          .transformList(collection);
    }
  };
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:23,代码来源:AlarmDefinitionSqlRepoImpl.java

示例10: searchType

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
public PageResponse<Code> searchType(PageRequest request) {
	Query query = super.createQuery("FROM WizardCode WHERE typeId = '0'");
	query.setResultTransformer(new ResultTransformer() {

		private static final long serialVersionUID = 1L;

		@Override
		public Object transformTuple(Object[] tuple, String[] aliases) {
			WizardCode wizardCode = (WizardCode) tuple[0];
			Code code = new Code();
			code.setPkId(wizardCode.getPkId());
			code.setNewId(wizardCode.getPkId());
			code.setTypeId(wizardCode.getTypeId());
			code.setContent(wizardCode.getContent());
			return code;
		}

		@Override
		@SuppressWarnings("rawtypes")
		public List transformList(List collection) {
			return collection;
		}

	});
	return super.pageQuery(query, request);
}
 
开发者ID:joaquinaimar,项目名称:wizard,代码行数:27,代码来源:CodeMaintainDao.java

示例11: bindTransformer

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
private static final SQLQuery bindTransformer(SQLQuery q, NativeQuery<?> query) {
    String[] retvals = newArray(String.class, map(Transformers.<String>left(), query.retvals));
    final OptionResultTransformer resultTransformer = new OptionResultTransformer(query.retvals);
    if (query instanceof NativeQuery.NativeQuerySingleEntity ||
        query instanceof NativeQuery.NativeQueryT1 ||
        query instanceof NativeQuery.NativeQueryVoid) {
        q.setResultTransformer(resultTransformer);
    } else {
        final TupleResultTransformer tupleResultTransformer = new TupleResultTransformer(retvals);
        q.setResultTransformer(new ResultTransformer() {
            @Override
            public Object transformTuple(Object[] tuple, String[] aliases) {
                Object[] ret = (Object[]) resultTransformer.transformTuple(tuple, aliases);
                return tupleResultTransformer.transformTuple(ret, aliases);
            }
            @SuppressWarnings("rawtypes")
            @Override
            public List transformList(List collection) {
                return collection;
            }
        });
    }
    return q;
}
 
开发者ID:solita,项目名称:query-utils,代码行数:25,代码来源:HibernateQueryExecutor.java

示例12: getResultColumnOrRow

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
@Override
   protected Object getResultColumnOrRow(
	Object[] row,
	ResultTransformer transformer,
	ResultSet rs, SessionImplementor session)
throws SQLException, HibernateException {
	return row[row.length-1];
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:CollectionElementLoader.java

示例13: getResultColumnOrRow

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
@Override
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)
throws SQLException, HibernateException {
	return resolveResultTransformer( transformer ).transformTuple(
			getResultRow( row, rs, session),
			getResultRowAliases()
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:CriteriaLoader.java

示例14: getHolderInstantiator

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
static private HolderInstantiator getHolderInstantiator(ResultTransformer resultTransformer, String[] queryReturnAliases) {
	if ( resultTransformer == null ) {
		return HolderInstantiator.NOOP_INSTANTIATOR;
	}
	else {
		return new HolderInstantiator(resultTransformer, queryReturnAliases);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:CustomLoader.java

示例15: getResultColumnOrRow

import org.hibernate.transform.ResultTransformer; //导入依赖的package包/类
@Override
   protected Object getResultColumnOrRow(
		Object[] row,
        ResultTransformer transformer,
        ResultSet rs,
        SessionImplementor session) throws SQLException, HibernateException {
	return rowProcessor.buildResultRow( row, rs, transformer != null, session );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:CustomLoader.java


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