Announcement Announcement Module
Collapse
No announcement yet.
sring & hibernate session factory problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • sring & hibernate session factory problem

    Hi!

    Does spring manage LocalSessionFactoryBean in some kind weak reference, because if my application is idle sometime, it creates it again..
    The problem is, that in hibernate make this transaction lookup factory for level 2 cache, and it takes LOT time, bootup can take about 40 seconds, and that isn't good thing..
    I cannot understand why it takes so much time, actually funny thing is, that it takes so much time only our product server, where we have dual processor..

    So, is there some way to prevent losing reference to session factory?

    Thanks already.

    - Artsi

  • #2
    Turn logging on and see what's going on with the FactoryBean. You can also look at the sources of Spring to see if it uses a weak references. I would say on your server you have some kind of aggressive GC that recycles objects very fast.
    For HB you can improve startup performance by serializing the configuration and then loading it - it's out of the box in HB3 and on the CVS (I think) for HB 2.1. See this page:http://www.hibernate.org/194.html

    Comment


    • #3
      Hi!

      Yes i have read sources.. and i cannot find nothing special..

      There is other program on same server, where we have self coded this hibernate stuff, creating SessionFactory and there everything works fine.
      Main difference is that in that application SessionFactory is maintained in class's static reference and it is created in startup, and it lives until process is terminated.

      The problem is that i really cannot reboot server all the time to resolve this feature, and like i said, i have encouter this problem only this one machine, and only this machine has dual processor.. has anyone test this combination on dual platform?!??

      This 40%-60% speedup is not sufficient..

      Comment


      • #4
        Originally posted by artsi
        Hi!

        Yes i have read sources.. and i cannot find nothing special..

        There is other program on same server, where we have self coded this hibernate stuff, creating SessionFactory and there everything works fine.
        Main difference is that in that application SessionFactory is maintained in class's static reference and it is created in startup, and it lives until process is terminated.

        The problem is that i really cannot reboot server all the time to resolve this feature, and like i said, i have encouter this problem only this one machine, and only this machine has dual processor.. has anyone test this combination on dual platform?!??

        This 40%-60% speedup is not sufficient..
        Where and how do you load your applicationContext?

        Comment


        • #5
          It's a web application. i use spring's MVC model.. I use dispatcher servlet. hm.. so.. and after all ( best one =)) i have extends spring's Dispatcher Servlet, and i implement SingleThreadModel in subclass... =) So is it so that every thread create new application context?!? =)

          oh dear.. =)

          Any hints what is correct way to do this? i think that i need this single thread model, because web application does some really heavy weight stuff and request's will take some time.. should i use ContextLoaderListener? i think that it will fix this..

          Comment


          • #6
            Originally posted by artsi
            It's a web application. i use spring's MVC model.. I use dispatcher servlet. hm.. so.. and after all ( best one =)) i have extends spring's Dispatcher Servlet, and i implement SingleThreadModel in subclass... =) So is it so that every thread create new application context?!? =)

            oh dear.. =)

            Any hints what is correct way to do this? i think that i need this single thread model, because web application does some really heavy weight stuff and request's will take some time.. should i use ContextLoaderListener? i think that it will fix this..
            Long time you need to process your requests is not really a reason to use the single thread model. If your servlets are threadsafe (no instance variables is a good sign), and they should be, there's no reason whatsoever to use it.

            Comment

            Working...
            X