Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

eclipselink stored procedures with result returned from different tables

 
Rene Ummels
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Will the book explain how to handle stored procedures? Some scenarios, for instance with EclipseLink and a mix of tables in the returned result.

We have made some stored procedure code, the result from the stored procedure containing a mix of two tables (destinationNumber from ported; networkRoutingPrefix from network).
Is the below way correct and efficient?










thanks,
Rene
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what book you are referring to.

Your stored procedure call seems ok. Although odd that you define it using annotations as a named query, but then create a new call to execute it. You could just use the named query (although if your call works, it seems your procedure returns a result-set not output parameters).
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rene,

We have tried to keep the book vendor-neutral and focused on the specification itself, and since stored procedures are not defined in the spec we did not include them. However, they are on my feature list for the JPA 2.1 specification, so there is a good chance they will be in the next edition of the book.

As James mentioned, since you are defining a named query you might want to stick with that and keep the vendor-specific code out of your method.
 
Rene Ummels
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Good feedback. So, if I understand you correctly this would mean to change the code as follows, right?




kind regards,
Rene
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no @ in the JPA query parameter name. It is just the name that you specified as the queryParameter when you defined the query, which was portedNumber.
 
Rene Ummels
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike.
I now substituted:

by:


Then I executed the createNamedQuery() code but I get an exception:
Caused by: java.lang.IllegalArgumentException: NamedQuery of name: ported.p_sel_number_info not found.
How can I solve this?


thanks,
Rene
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rene,

Your entity manager should be from the EMF of the same persistence unit as the Result entity or the query name won't be in that namespace. If you think that is okay in your app then you might want to go through the EclipseLink forums for more specific help. They are pretty helpful there.
 
Rene Ummels
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The actual solution was to update the sybase stored procedure from:

to:


In this way, the columns were mapped correctly.


br,
Rene
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic