facebook

Hibernate session/cache problem in tomcat 5.5

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #255643 Reply

    pablogmuller
    Member

    Hi,
    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.

    #255646 Reply

    Riyad Kalla
    Member

    You 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.

    #255690 Reply

    pablogmuller
    Member

    Thanks 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.

    #255694 Reply

    Riyad Kalla
    Member

    Try 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?

    #255697 Reply

    Haris Peco
    Member

    pablogmuller ,

    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 operation

    Best regards

    #255720 Reply

    pablogmuller
    Member

    Thanks 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

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Hibernate session/cache problem in tomcat 5.5

You must be logged in to post in the forum log in