- This topic has 5 replies, 3 voices, and was last updated 18 years, 6 months ago by pablogmuller.
-
AuthorPosts
-
pablogmullerMemberHi,
I have a web application that has some database interaction with hibernate. It has to perform both queries and updates/inserts. I works “fine”, but the changes I make are not visible for hibernate until I restart Tomcat. I’ve been reading this post:
http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-5415-view-next.html
It says that I have to create a new session for each transaction, so I’m closing the session after each insert/update, so the next time I query the database It will create a new session (right?).
This isn’t working. What am I missing? Am I doing the right thing, what should I do instead?.
Thanks a lot.
Riyad KallaMemberYou don’t need to create a new session each time but you do need to commit the transaction or try flushing the session to see if that is the problem.
pablogmullerMemberThanks for the reply Riyad.
I did that too, but it didn’t work either. I’ll keep trying… Any suggestion will be welcome.
I’m using MS SQLServer 2000.
Thanks again.
Riyad KallaMemberTry using the JTDS driver (http://jtds.sourceforge.net/) from source forge for SQL Server, the default JDBC driver from Microsoft is pretty bad (buggy). I don’t know if that would help, but maybe posting some examples of your code and we might be able to see the problem?
Haris PecoMemberpablogmuller ,
If you want reload objects which changed out of hibernate (database triggers, other application etc) you can use : session.refresh(ent).
Unfortunately, you have to refresh only one object/entity with this method, but it’s only what hibernate offer – hibernate have great caching mechanism and refreshing complete session can be performace downgrade.
You can call rebuild session factory, of course, but it is time consuming operationBest regards
pablogmullerMemberThanks a lot to both of you!!!
It’s working now.
I’m opening a transaction, doing the update/insert I need, commiting and, when I have to query the database I refresh the objects.
I’ll give a try to JTDS.
Pablo -
AuthorPosts