-->
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.  [ 7 posts ] 
Author Message
 Post subject: Flush not flushing?
PostPosted: Wed Oct 13, 2004 11:14 am 
Newbie

Joined: Wed May 12, 2004 7:48 am
Posts: 5
Location: Belgium
I'm using Hibernate 2.1.6 and I've got a problem with flushing a session.

I create a new object and would like to have the insert query run immediately after:

Code:
session.save(link);
log.debug("BEFORE");
session.flush();
log.debug("DONE");


with link being the new object to save... When I look in my log files no query is executed between the BEFORE and DONE part, the query is ran the next time a select query is executed..

Why does this doesn't work? Is there another way around this?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 11:18 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
take a look in the reference-guide on page 73 - Chapter 9.7 "Ending a session" ...

You've simply forgot the "commit" if i'm looking right ...

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 14, 2004 2:19 am 
Newbie

Joined: Wed May 12, 2004 7:48 am
Posts: 5
Location: Belgium
Sinec the transaction is handled by the database, the insert query and the commit are seperate things..

I have defined some restrictions on the database, if a user insert a new object that violates these restrictions I want to be able to catch the exception and warn the user of his mistakes.

Even after the insert has taken place, the user still can rolback the transaction.

I want to force Hibernate to generate and run the query, without the commit statement...

any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 14, 2004 2:25 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
I don't know the answer for the flush. But I think what you're trying will not work any way. Read my post at the end of topic http://forum.hibernate.org/viewtopic.php?t=935195.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 14, 2004 2:39 am 
Newbie

Joined: Wed May 12, 2004 7:48 am
Posts: 5
Location: Belgium
I find a strange that you would have to implement all the unique checks located on the db again in your app... The database outlives your application, so I would think the database is in charge of the uniqueness of the data...

Besides that, there is no way for me to force Hibernate into executing the query without committing the transaction?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 14, 2004 2:51 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Welcome to Java database application development. Its strange, but it works. There is no way you can have only database constraints and skip the validation in your app layer. No, not even with unified database exceptions.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 14, 2004 2:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
P.S. session.flush() synchronizes the Session state with the database, ie. it executes SQL. I don't know why it doesn't work for you though.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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