Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JPA problem with Native Query

  Asked By: Bill    Date: Jun 06    Category: Java    Views: 1681
  

I am using JPA (Hibernate 3) in a legacy application. I want to migrate all JDBC queries to Native Query in JPA. The problem is
I can not use @SqlResultSetMapping in my logic. In some methods I have more than 10 queries that each one selects one column
of a Table (or executes a stored procedure). I want to get the exact ResultSet object after executing Native Queries in JPA. Is it possible?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Damian Jones     Answered On: Jun 06

JPA is for OO programs which need a OO view of persistence storage.
if you want exact resultSet then JPA is not much a good choice for you.
for example if you want feed this result into a report or OLAP software, which user creates a SQL to run you may prefer to bypass JPA
please refer to "Fast Lane Reader" pattern
in such a cases create a "Session Facade" for this set of queries  that runs all "Stored Procedures" and "Native Queries" with special set set of columns in result set.

 
Answer #2    Answered By: Eamon Jones     Answered On: Jun 06

I agree you about JPA and we use JPA (Hibernate 3) for this purpose. these queries
that I have to run natively are about only 5% of all persistence layer but they are exist
and I can't find a way to run them with JPA/Hibernate. Now I am working on a solution
that someone suggessted on the web and if it was correct and helped I will tell about
that.

 
Didn't find what you were looking for? Find more on JPA problem with Native Query Or get search suggestion and latest updates.




Tagged: