e ae galera!
seguinte, estou tendo algumas dúvidas com relação a utilização do hibernate chamando uma stored procedure…
na minha busca pela internet, encontrei a seguinte informação:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<sql-query name="selectPaymentMaster_SP" callable="true">
<return alias="paymentMaster" class="com.gateway.payment.model.PaymentMaster">
</return>
{ call OC_PAYMENT_METHOD_SEL(?, PaymentTypeCode, :callingAPI) }
</sql-query>
</hibernate-mapping>
e isso também:
public List<PaymentMaster> search(PaymentMasterSearch paymentMasterSearchValue) throws PaymentException {
LOGGER.debug(" $$$---Start of search method in the PaymentMasterService:");
Session sessionObj;
List<PaymentMaster> paymentMasterlist;
try {
if (paymentMasterSearchValue != null) {
sessionObj = HibernateUtil.currentSession();
String keyWord = paymentMasterSearchValue.getSearchKeyWord();
paymentMasterlist = sessionObj.getNamedQuery("selectPaymentMaster_SP")
.setParameter("paymentTypeCode", keyWord)
.setParameter("callingAPI", "OC25")
.list();
HibernateUtil.closeSession();
} else {
LOGGER
.debug(" $$$--Invalid payment master Search data.");
throw new PaymentException(
"Invalid payment master Search data.");
}
} catch (Exception ex) {
LOGGER.error("Could not find a payment master Record." , ex);
throw new PaymentException("Error in Proccessing the search method.",ex);
}
return paymentMasterlist;
}
o detalhe é o seguinte:
eu só quero passar parametros pra essa procedure, não quero um retorno… mas pelo oq tambem li, se não entendi errado, o MSSQL tem que retornar alguma coisa de uma store procedure… alguém que já trabalhou com isso poderia confirmar?
bom, até então estou assim:
[code]<?xml version="1.0" encoding="UTF-8"?>
{ call SP_IMPORTA_ERP(?, ?, ?, ?, ?, ?, ?, ?) } [/code] [code] public void setData() { Session session; try { session = HibernateUtil.getSession(); session.getNamedQuery("importDataFromERP").setParameter( ???, ??? ).setParameter( ???, ??? ).list?!; session.close();
} catch (Exception ex) {
throw new ClientException("Erro na importação. Verifique os parametros");
}
}
[/code]
nao sei se estou fazendo o mapeamento corretamente nem se estou passando esses parametros para a procedure corretamente…
fico no aguardo do help…
desde ja, grato