Question

I am looking for an answer for a small problem I have. I think there is a theoretical concept I am not aware of. Please help:

I have stored procedure that collects data from various tables and views. 'sp_getData()'

At various points, it writes the intermediate results to a 'table_A', by either INSERT or UPDATE. At the end of stored procedure, it outputs the data collected in 'tbl_A' with the simple select

select field1, field2, ..etc...
from tbl_A
where <someCondition is met>

tbl_A is static, and is supposed to keep the data in it after stored procedure ends.

If I run this stored procedure from SQLServer query analyzer - everything is fine, the table stays. However if I call stored procedure from java application using Hibernate, the tbl_A is empty. However, I DO GET RESULTS SET in Java application.

Here is the Java code part:

  private void execute(Session session, int port) throws MyCustomSystemException{
     String queryString = "{ call sp_getData(?) }";
    Query q;
    List resultList;
    try {
        q = session.createSQLQuery(queryString);
        q.setInteger(0, port);
        resultList = q.list();
    } 
    catch (HibernateException hex) {
         throw new MyCustomSystemException(
                "STYSTEM ERROR:  Can't execute    
                      sp_getData(?) procedure.",
                hex);
    }

    if (isSummaryReport())
        merge(resultList);
            System.out.println("==============") ;
    if (isFullReport())
        merge2(resultList);
   }

I am using Hibernate-Version: 3.1.3

merge() and merge2() are methods that process the data returned. The contain no database related / hibernate code.

Can anyone help ??? Thank you.

Était-ce utile?

La solution

Try switching call sp_getdata(?) to exec sp_getdata()

Difference Between call and exec in SQL

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top