-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: JPA Executing merge and sql procedure in single transaction
PostPosted: Fri Sep 14, 2012 1:44 pm 
Newbie

Joined: Wed Oct 29, 2003 6:50 pm
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.