title: Spring - Can you recompile a StoredProcedure after initialization?
body: <p>I have a <a href="http://docs.spring.io/spring-framework/docs/2.0.8/api/org/springframework/jdbc/object/StoredProcedure.html" rel="nofollow">StoredProcedure</a> which is compiled on initialization. </p>
  
  <p>Occasionally the logic requires that I use a different stored procedure. </p>
  
  <p>I have tried and failed to reset the name of the stored procedure. The data is still retrieved using the original stored procedure.</p>
  
  <p>Is there a way to achieve this? </p>
  
  <p>Here is a reduced version of the class showing initialization and attempted recompiling with the name of a different stored procedure:</p>
  
  <pre><code>import org.springframework.jdbc.object.StoredProcedure;
  
  public class MyDAOImpl extends StoredProcedure implements MyDAO {
  
      @Autowired
      public MyDAOImpl(DataSource dataSource, String originalSPName) {
          super(dataSource, originalSPName); // invokes StoredProcedure constructor
          compile();
      }
  
      public List&lt;String&gt; useOtherStoredProcedure(){
          super.setSql("otherSPName");
          compile();
  
          // Error: Data is still retrieved with original StoredProcedure name 
          Map&lt;String, Object&gt; data = this.executeSP();
      }
  }
  </code></pre>