• 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

JPA and mapping result sets to POJO:s

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy all!

I have a couple of sp:s I'm calling and a few returns a result set when things go wrong. I'm trying to map those to POJO:s but it's not going well.

My NamedNativeQueries:


The InserLeaseError class:


And the code that ties it all together:


I'm running Hibernate 3.5.5 as persistence provider and I get these errors:



I was surprised that you can use TypedQueries for native queries (the 'getFreeIds' named query works perfectly).

Googling around I've found a few uses cases where the result set is mapped on pojos but there are not much detail.
The Pro JPA2 book by Mike Keith doesn't seemt to address the problem at all.
Thankful for any help here

cheers
Erik
 
E Erik Svensson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found it myself.
The class that maps the result set needs to be an Entity.
It also needs an id. My problem was then that the rows of the result set were not guaranteed to be unique so I had to add the row index to the result set.
Then it worked as desired.
reply
    Bookmark Topic Watch Topic
  • New Topic