• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using hash maps in native query for JPA 2.0

 
Kaiser Be
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

excited about my first post here. I wanted to know if i could use a hash map in my native query as in the example below. I would like to create a virtual column with using values from a hash map based on the current value of the item_subtype. if it doesnt exist in the hashmap then put fail.


Select
(case
when item_Meta_Data.ITEM_SUBTYPE = 'TEST' then 'HASHMAP.get( item_Meta_Data.ITEM_SUBTYPE)'
else 'fail'
end ) document_type_alias ,
c_item.* , item_Meta_Data.*

from
DR_CORE03.V_CONTAINER_ITEM c_item ,
DR_CORE03.v_item_metadata item_Meta_Data
where
c_item.ITEM_EXTERNAL_ID = item_Meta_Data.ITEM_EXTERNAL_ID
order by
document_type_alias


if this is not possible do you guys know what might be a better solution.

Thanks in advance
 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
Could you try to explain a bit more what you are trying to do?
Please elaborate on all of your related entities.
If there are any stacktraces, those might help as well.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming your HashMap contains your arguments in Java, you just need to use a parameter in your SQL query.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic