本文整理汇总了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;
}
}
示例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;
}
}
示例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
);
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
};
}
示例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);
}
示例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;
}
示例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];
}
示例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()
);
}
示例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);
}
}
示例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 );
}