Announcement Announcement Module
No announcement yet.
StoredProcedure not reusable and not threadsafe? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • StoredProcedure not reusable and not threadsafe?

    I have an Oracle stored procedure which returns a result set (ref cursor). I tried to access it through a StoredProcedure object with a parameter of class SqlReturnResultSet.

    As the mapping between the result set columns and my POJO is not entirely trivial I can't rely on the constructors based on a RowMapper so I use the one that takes a RowCallbackHandler as a parameter.

    As the RowCallbackHandler is stateful and kept in an instance variable it turns out that the StoredProcedure is no more thread safe and, even worse, not reusable because result accumulate.

    Two things would help to alleviate the problem:

    a) a SqlReturnResultSet constructor that takes a factory of RowCallbackHandler (the constructor that takes a RowMapper in fact let the parameter itself behave like a factory),

    b) a new ResettableRowCallbackHandler interface that is able to clear results from previous invocations.

    Bye, Fabio

  • #2
    I agree that the RowCallbackHandler is not ideal since it compromises the threadsafety - a factory might be a good idea. Could you enter a feature request in JIRA -