Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Hibernate use getCurrentSession() instead of openSession()

    Hello,

    is it possible that SmartGwt uses org.hibernat.SessionFactory::getCurrentSession() instead of org.hibernat.SessionFactory::openSession()? The reason is, that I use the org.hibernate.context.internal.ManagedSessionContext to provide a Context-Specific HibernateSession. The HibernateSession will be used in a custom DMI-Handler and in some ServletFilters before SmartGwt is invoked.
    Now if you use openSession a second HibernateSession will be created, which results in some Exceptions when I use the objects of DSResponse in my own HibernateSession.

    Maybe you can make it configurable to switch the desired behaviour.

    (I use the evaluation enterprise version 3.1d 2012/10/11)

    #2
    Hello,

    @isomorphic: can you give a statement on this thread please. Maybe there is also a way to hook into the SessionFactory construction to do some customization on it?

    Comment


      #3
      Yeah, that would be awesome. Right now, I've a problem with the Hibernate filters that I defined in my Grails application. They are enforced in the session that Grails creates for a request but are inactive in the one that is created by the SGWT server component just after the Grails one. I'm not sure though, whether this really would solve the problem but to me its sound plausible that it does.

      Comment


        #4
        Have you two already looked at the Hibernate integration docs and the ability to get the Hibernate Configuration via Spring? That may allow you to do what you want.

        Comment


          #5
          At the moment I doesn't use spring and I don't want to integrate spring just for that reason.
          As a workaround I have overridden the method buildSessionFactory() of the Configuration to setup some custom initialization.

          @isomorphic: I realized, that you create a new SessionFactory for every Request. This is a very bad practice, because the creation is an expensive operation. That's the reason Hibernate introduced multi-tenancy in 4.0. So you can use one SessionFactory for all request, even if they belong to different schemes or databases.

          Comment


            #6
            This doesn't seem to be the case. We hold onto the sessionFactory as a static variable. Possible you are seeing this as an artifact of your attempt to return a custom Configuration.

            Comment

            Working...
            X