-->
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: session.save method does not execute correctly
PostPosted: Sun Dec 25, 2005 10:22 pm 
Newbie

Joined: Fri Sep 23, 2005 4:07 am
Posts: 4
sometimes, the save method of Session executes but no insert statement is displayed in console as usual although I set show_sql=true and no data is inserted into database. I'm using hibernate 3.0, Tomcat web server, Netbeans IDE.

Thanks a lot for consideration


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 5:39 am 
Beginner
Beginner

Joined: Sat Dec 17, 2005 1:24 pm
Posts: 42
Location: Berlin, Germany
There may be a lot of reasons, why this happens. One of the (in my opinion) less obvious reasons I encountered once was that I used declarative transaction demarcation and the surrounding transaction was marked as "read-only". This seems to prevent any updates.

But to really help you, I assume that more information on the problem is needed!?

All the best,

René


Top
 Profile  
 
 Post subject: Re: session.save method does not execute correctly
PostPosted: Tue Dec 27, 2005 2:37 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
phuongjali wrote:
sometimes, the save method of Session executes but no insert statement is displayed in console as usual although I set show_sql=true and no data is inserted into database. I'm using hibernate 3.0, Tomcat web server, Netbeans IDE.

Thanks a lot for consideration


Hibernate will execute the queries when the session is flushed or closed.
So your insert query will only be displayed when any of the above happens.


Top
 Profile  
 
 Post subject: does hibernate ignore the query?
PostPosted: Wed Dec 28, 2005 6:48 am 
Newbie

Joined: Fri Sep 23, 2005 4:07 am
Posts: 4
Thanks a lot

Usually, when transaction.commit() is call, the query is printed out. But sometimes it doesn't and no data is insert into database. When I try again or restart server a few time, it's become good. I agree that data will insert into database when session.flush() or close() is called, but they're used to make the hibernate immediately do the query. When we don't use them, but commit(), the query must a done at certain time, When??. I see that it usually be done immediately. I beleive that hibernate don't ignore our query???


Top
 Profile  
 
 Post subject: Re: does hibernate ignore the query?
PostPosted: Wed Dec 28, 2005 12:03 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
phuongjali wrote:
When I try again or restart server a few time, it's become good.

I am assuming you are using threadlocal sessions. The above statement indicates you might not be closing your sessions properly.

If you are using transactions, the commit causes the session to flush automatically.


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.