aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate - Stored  Procedure -turn off auto commit and i get a lock on a table. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Hibernate - Stored  Procedure -turn off auto commit and i get a lock on a table." Watch "Hibernate - Stored  Procedure -turn off auto commit and i get a lock on a table." New topic
Author

Hibernate - Stored Procedure -turn off auto commit and i get a lock on a table.

Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 75
hi guys

I hope you can help me here. My underlying database is Microsoft SQL Server. This by default has auto commit in place

from hibernate i am calling a stored procedure which inserts and updates rows in a few different database tables. I call the stored proc like so:


I know this may not be the right way. But it works. The data commits right away. thats my issue. I do not want autocommit in place as I want to carry out further data manipulation under the one transaction
What I need to do is query the database for the changes the stored proc carried out
Query query=session.getNamedQuery("myNamedQuery");
(List<StoredProcObjects>)query.list();
and carry out further updates on the objects. At this point I want to commit everything or rollback if i hit an issue.

To avoid autocommit I have set in the stored proc



And in my code I have attempted to set the connection like so


When i do these the data does not autocommit but calling

freezes as the table(s) are locked as the stored proc has not yet committed. I need to be able to do a dirty read and do further changes on the dirty data.

Any help here is much appreciated. Everything works fine if i leave autocommit in place but this is dangerous as the stored proc could commit data and the extra updates fall over. DOing all the work in the stored proc is not an option

Thanks
Alan
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hibernate - Stored Procedure -turn off auto commit and i get a lock on a table.
 
Similar Threads
Hibernate; error executing stored procedure
When is exclusive lock released
Help required for hibernate query (HQL) calling stored procedure
Help required for hibernate query (HQL) calling stored procedure
Problem with stored procedure in Hibernate