Forums Register Login

eclipselink stored procedures with result returned from different tables

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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).
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Hi,

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




kind regards,
Rene
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Hi,

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

to:


In this way, the columns were mapped correctly.


br,
Rene
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 5070 times.
Similar Threads
call a stored procedure using eclipselink Problem...
output parameter from stored procedure: Operand type clash: VARCHAR is incompatible with VOID Type
JPA and StoredProcedureCall
Calling Stored Procedure thru JPA
stored procedure exception (primary key null)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:45:05.