jsr338-experts@jpa-spec.java.net

[jsr338-experts] Re: StoredProcedure clarification

From: gordon yorke <gordon.yorke_at_oracle.com>
Date: Tue, 06 Aug 2013 16:41:29 -0300

getUpdateCount() should return the updateCount and "move on" to the next
result as there is no other API available to advance to the next result
for update counts or result sets. If the API is being used on a
StoredProcedure with an unknown result structure when a user encounters
a -1 for an updateCount() the user would then call hasMoreResults() to
determine if they are at the end of the results.

On 26/07/2013 7:26 PM, Steve Ebersole wrote:
> Related:
>
> EntityManager em = ...;
> StoredProcedureQuery query = em.createStoredProcedureQuery(...);
> query.getUpdateCount();
> query.getUpdateCount();
> query.getUpdateCount();
> ...
>
> Even say it "does the right thing":
> StoredProcedureQuery query = em.createStoredProcedureQuery(...);
> query.execute();
> query.getUpdateCount();
> query.getUpdateCount();
> query.getUpdateCount();
>
> Javadoc for getUpdateCount says "Return the update count or -1 if
> there is no pending result or if the next result is not an update count."
>
> The part that bothers me is the "next result" bit. To me that
> indicates that we are supposed to "move on" to the next result. But
> say the next logical result is a ResultSet. I guess I am not seeing
> the consistent way to cycle through the ResultSets/updateCounts if the
> TCK tests are how this is supposed to work. All these situations are
> exactly things done in the TCK.
>
>
> On Fri 26 Jul 2013 05:16:44 PM CDT, Steve Ebersole wrote:
>> EntityManager em = ...;
>> StoredProcedureQuery query = em.createStoredProcedureQuery(...);
>> query.getUpdateCount();
>>
>> What should happen above when getUpdateCount() is called? The
>> "result" corollaries (getResultList, getSingleResult) specifically say
>> that the query will be executed when they are called. getUpdateCount
>> conspicuously says nothing on the subject. Nor does it call out being
>> allowed to throw an exception in this case. So should I assume that
>> getUpdateCount() should just return -1 here?
>>
>> Yes, its a silly case, but the TCK does it. Many times...
>>
>>