• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using hash maps in native query for JPA 2.0

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 177
Hibernate Python Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming your HashMap contains your arguments in Java, you just need to use a parameter in your SQL query.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic