I am using named query for returning List<?>
. But now i have a requirement that i have to return a Map<key,value>
so that i can filter the duplicates using the key..
I have a named query to return a List<String>
for product names,
<named-query name="FETCH_ACTIVE_PRODUCTS_NAME" >
<query>SELECT product.name FROM Product product
WHERE product.name LIKE :name
</query>
</named-query>
another named query to fetch a List<String>
for product descriptions,
<named-query name="FETCH_ACTIVE_PRODUCTS_DESC" >
<query>SELECT product.desc FROM Product product
WHERE product.desc LIKE :desc
</query>
</named-query>
Another named query which fetches the product id's by product name
<named-query name="FETCH_ACTIVE_PRODUCTS_ID_BY_NAME" >
<query>SELECT product.id FROM Product product
WHERE product.name LIKE :name
</query>
</named-query>
Now I have to return a Map<Long,String>
with key and value..key containing the product id and values containing the product name and description..the key should not contain duplicate values(i.e. duplicate product id's)..
Now my problem is how can i return a Map<Long,String>
in named query..I've got no help from google...
Any one have ideas about how to do this..