-->
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.  [ 4 posts ] 
Author Message
 Post subject: Disable Transactions for Hibernate calling Stored Procedures
PostPosted: Wed Nov 14, 2012 10:35 pm 
Newbie

Joined: Wed Nov 14, 2012 10:02 pm
Posts: 3
Hi All,

For our web application, all DB access is performed via stored procedures. This design decision is set in stone and there is no way I can change it.

Additionally, all transaction handling is done within the stored procedures. The Java layer must not use transactions.

I can easily accomplish this using plain JDBC. But I’d prefer to use Hibernate for its ORM and caching features.

Calling stored procedures with Hibernate is easy:

Code:
final Session session = sessionFactory.getCurrentSession();
final Query query = session.createSQLQuery("EXEC dbo.SP_ProductSearch :searchStr").addEntity(Product.class).setString("searchStr", "ap");
return query.list();


But when I run a DB profile, I see the following.

Code:
SET IMPLICIT_TRANSACTIONS ON
EXEC dbo.SP_ProductSearch  N'ap'
IF @@TRANCOUNT > 0 COMMIT TRAN
IF @@TRANCOUNT > 0 COMMIT TRAN
SET IMPLICIT_TRANSACTIONS OFF


Is there anyway I can disable the 4x transaction statements?

My technology stack is as follows.

Spring 3.1.2
Hibernate 4.1.8
jTDS (JDBC driver) 1.2.5
MS SQL Server 10.x

Many thanks in advance... Adam.


Top
 Profile  
 
 Post subject: Re: Disable Transactions for Hibernate calling Stored Procedures
PostPosted: Sun Nov 18, 2012 5:04 pm 
Newbie

Joined: Wed Nov 14, 2012 10:02 pm
Posts: 3
Any ideas folks?


Top
 Profile  
 
 Post subject: Re: Disable Transactions for Hibernate calling Stored Procedures
PostPosted: Mon Nov 19, 2012 4:47 pm 
Newbie

Joined: Wed Nov 14, 2012 10:02 pm
Posts: 3
I haven't discovered any way to prevent Hibernate from using transactions, so as a work-around I've switched to MyBatis which works perfectly.

http://www.mybatis.org/spring/index.html


Top
 Profile  
 
 Post subject: Re: Disable Transactions for Hibernate calling Stored Procedures
PostPosted: Wed Nov 28, 2012 12:30 am 
Newbie

Joined: Wed Nov 28, 2012 12:21 am
Posts: 1
Nice post-------

_________________
ali123-----


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

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.