-->
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.  [ 3 posts ] 
Author Message
 Post subject: insert query Vs call procedure.
PostPosted: Wed Jul 23, 2008 6:39 am 
Newbie

Joined: Thu Jun 19, 2008 9:55 am
Posts: 3
Hi,

I am using Hibernate version:3.0 and oracle 10.

In my method, first will execute 4 insert query. after executing all insert queries , finally it should be calling a procedure and commit the transaction.

My problem is when i calling this method, what hibernate does is,first calling the procedure and then executing all insert queries.

Why is it doing like this? Is there any configuration required to tell which kind of query should execute first ?.

Help needed.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:28 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Hibernate is holding the changes in its cache, and not committing those changes to the database until the Session is closed or the transaction is committed. Since this is happening after the procedue, you see the procedure going first, and then the updates.

So, commit your changes earlier, and it should all work!

You might find this tutorial on How Hibernate Works to be interesting:

A Quick Discussion: What is Hibernate? and How Does it Work?

JavaRanch Thread on Same Topic

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 7:00 am 
Newbie

Joined: Thu Jun 19, 2008 9:55 am
Posts: 3
Thanks for reply.

You mean Once completed the insertion, commit the changes. then, again call the procedures with new transaction.

like this,

session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save();
session.save()
session.save()
session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();

session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();

call the procedure();
call the procedure();

session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();


Am i correct?

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.