public class MapResultTransformer<K,V> extends Object implements org.hibernate.transform.ResultTransformer
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.
Modifier and Type | Field and Description |
---|---|
static String |
KEY_ALIAS |
static String |
VALUE_ALIAS |
Constructor and Description |
---|
MapResultTransformer() |
Modifier and Type | Method and Description |
---|---|
List |
transformList(List tuples)
|
Object |
transformTuple(Object[] tuple,
String[] aliases)
Transform the tuple into a key/value pair.
|
public static final String KEY_ALIAS
public static final String VALUE_ALIAS
public Object transformTuple(Object[] tuple, String[] aliases)
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.
transformTuple
in interface org.hibernate.transform.ResultTransformer
tuple
- tuple to be transformed to a key/value pairaliases
- column aliasesCopyright © 2022. All rights reserved.