Class MapResultTransformer<K,V>
java.lang.Object
io.hypersistence.utils.hibernate.query.MapResultTransformer<K,V>
- All Implemented Interfaces:
Serializable,org.hibernate.query.ResultListTransformer,org.hibernate.query.TupleTransformer,org.hibernate.transform.ResultTransformer
public class MapResultTransformer<K,V>
extends Object
implements org.hibernate.transform.ResultTransformer
The
MapResultTransformer allows us to return
a Map from a JPA Query.
If there are aliases named as key or value,
then those will be used.
Otherwise, the first column value is the key while the second one is the Map value.
For more details about how to use it, check out this article on vladmihalcea.com.
- Since:
- 2.9.0
- Author:
- Vlad Mihalcea
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontransformList(List tuples) transformTuple(Object[] tuple, String[] aliases) Transform the tuple into a key/value pair.
-
Field Details
-
KEY_ALIAS
- See Also:
-
VALUE_ALIAS
- See Also:
-
-
Constructor Details
-
MapResultTransformer
public MapResultTransformer()
-
-
Method Details
-
transformTuple
Transform the tuple into a key/value pair.If there are aliases named as
keyorvalue, then those will be used.Otherwise, the first column value is the key while the second one is the Map value.
- Specified by:
transformTuplein interfaceorg.hibernate.query.TupleTransformer<K>- Parameters:
tuple- tuple to be transformed to a key/value pairaliases- column aliases- Returns:
- unmodified tuple
-
transformList
-