Skip to content

Instantly share code, notes, and snippets.

@sebersole
Created September 13, 2016 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebersole/bc721caa20a5e4a97cbde44567b0b2ea to your computer and use it in GitHub Desktop.
Save sebersole/bc721caa20a5e4a97cbde44567b0b2ea to your computer and use it in GitHub Desktop.
package org.hibernate.query;
import java.util.List;
/**
* Allows defining transformation of the result List from a Query from
* one form to another.
*
* @see TupleTransformer
*
* @author Steve Ebersole
* @author Gavin King
*/
public interface ResultListTransformer {
/**
* Here we have an opportunity to perform transformation on the
* query result as a whole. This might be useful to convert from
* one collection type to another or to remove duplicates from the
* result, etc.
*
* @param resultList The result list as would otherwise be returned from
* the Query without the intervention of this ResultListTransformer
*
* @return The transformed result.
*/
List transformList(List resultList);
}
package org.hibernate.transform;
import java.io.Serializable;
import org.hibernate.query.ResultListTransformer;
import org.hibernate.query.TupleTransformer;
/**
* Implementors define a strategy for transforming query results into the
* actual application-visible query result list.
*
* @see org.hibernate.Criteria#setResultTransformer(ResultTransformer)
* @see org.hibernate.query.Query#setResultTransformer(ResultTransformer)
*
* @author Gavin King
*
* @deprecated ResultTransformer is no longer supported. It has been split
* into {@link TupleTransformer} and {@link ResultListTransformer}
*/
@Deprecated
public interface ResultTransformer extends TupleTransformer, ResultListTransformer, Serializable {
}
package org.hibernate.query;
/**
* Defines a strategy for free-form transformations of the query result
* tuples (the result "row").
* <p/>
* To be determined : the effect between TupleTransformer, result-type and dynamic-instantiations
*
* @author Steve Ebersole
* @author Gavin King
*/
public interface TupleTransformer<T> {
/**
* Tuples are the elements making up each "row" of the query result.
* The contract here is to transform these elements into the final
* row shape.
*
* @param tuple The result elements
* @param aliases The result aliases ("parallel" array to tuple)
*
* @return The transformed row.
*/
T transformTuple(Object[] tuple, String[] aliases);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment