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.  [ 5 posts ] 
Author Message
 Post subject: Extra inserts & deletes during select
PostPosted: Wed Jan 20, 2010 4:59 pm 
Newbie

Joined: Wed May 20, 2009 9:49 am
Posts: 11
Hello there!
I have an interesting issue: when I perform a rather cumbersome select-query to the database, I can see a lot of deletes and inserts in sql-commands stack. Can anyone tell what does this mean?


Top
 Profile  
 
 Post subject: Re: Extra inserts & deletes during select
PostPosted: Wed Jan 20, 2010 6:15 pm 
Beginner
Beginner

Joined: Wed Jun 28, 2006 2:24 pm
Posts: 30
Location: Brazil
The flush occurs before a query. So, when you execute a select, the Hibernate sync the database before.


Top
 Profile  
 
 Post subject: Re: Extra inserts & deletes during select
PostPosted: Thu Jan 21, 2010 2:33 am 
Newbie

Joined: Wed May 20, 2009 9:49 am
Posts: 11
Oh, thanks a lot! Now everything is clear.


Top
 Profile  
 
 Post subject: Re: Extra inserts & deletes during select
PostPosted: Thu Jan 21, 2010 3:19 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
You can also disable the auto-flush by executing queries, if you wish:

query.setFlushMode(FlushMode.COMMIT);

this above is for single queries.
You can also disable auto-flush generally for a entire session:

session.setFlushMode(FlushMode.COMMIT)

or entityManager.setFlushMode(FlushMode.COMMIT)

if you use JPA approach


Top
 Profile  
 
 Post subject: Re: Extra inserts & deletes during select
PostPosted: Sat Jan 23, 2010 3:19 am 
Newbie

Joined: Wed May 20, 2009 9:49 am
Posts: 11
Thanks!


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