|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vladmihalcea.hibernate.type.util.MapResultTransformer<K,V>
public class MapResultTransformer<K,V>
The MapResultTransformer
allows us to return
a Map
from a JPA javax.persistence.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.
Field Summary | |
---|---|
static String |
KEY_ALIAS
|
static String |
VALUE_ALIAS
|
Constructor Summary | |
---|---|
MapResultTransformer()
|
Method Summary | |
---|---|
List |
transformList(List tuples)
Return the Map instead of the default List . |
Object |
transformTuple(Object[] tuple,
String[] aliases)
Transform the tuple into a key/value pair. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String KEY_ALIAS
public static final String VALUE_ALIAS
Constructor Detail |
---|
public MapResultTransformer()
Method Detail |
---|
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 aliases
public List transformList(List tuples)
Map
instead of the default List
.
transformList
in interface org.hibernate.transform.ResultTransformer
tuples
- tuples
Map
result set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |