Hi,
I have a problem with the following code:
EntityTransaction et = em.getTransaction(); try { et.begin(); t = em.merge(t); Query q = em.createNativeQuery("exec sp_RecalculatePaymentAllocation @AccountID='"+t.getAccountID()+"',@OBID='"+t.getOurBranchID()+"' , @Type='"+type+"'"); q.executeUpdate();
et.commit();
Everything gets saved and executed but the sql procedure doesn't see the changes in the database and calculated values are wrong.
In a similar case where a new object is created with e.persist(t) rather than merged everything works fine.
Switching to two separate transactions resolves the issue but that's not what we want. Here is the working code:
et.begin(); t = em.merge(t); et.commit();
et = em.getTransaction(); et.begin(); Query q = em.createNativeQuery("exec sp_RecalculatePaymentAllocation @AccountID='"+t.getAccountID()+"',@OBID='"+t.getOurBranchID()+"' , @Type='"+type+"'"); q.executeUpdate(); et.commit();
Is that a bug? Is that an issue with Hibernate or with the jdbc provider? Any thoughts or suggestions?
Environment: JPA Hibernate 3.6.10.Final JTDS 1.2.6 SQL Server 2008
Thanks, Oz
|