Results 1 to 3 of 3

Thread: SLSB caching hibernateSessionFactory

  1. #1
    Join Date
    Dec 2004
    Location
    London
    Posts
    51

    Question SLSB caching hibernateSessionFactory

    Hi,

    I was wondering what the best method of caching the hibernateSessionFactory in the business layer is.

    I am using SLSB, business pojo (extends AbstractStatelessSessionBean), DAO, Hibernate. Before attempting to introduce a layered architecture, I was storing the hibernateSessionFactory in a static SLSB member variable which renders the state cached - if I understand the SLSB behaviour correctly.

    Question is now, can I do the same with the bizpojo interface and declare it as a static variable.

    Anyone have any idea what the overhead would be like for a few hundred hits per minute max on a jndi-lookup for the hibernateSessionFactory taking place for every request?

    The reason I ask is that I am not sure that the hibernateSessionFactory which is defined in my applicationContext.xml will be cached otherwise.

    Any help is much appreciated.

    Jim

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    If you want to share a SessionFactory between multiple SLSBs maybe you could have a look at ContextSingletonBeanFactoryLocator.

    Regards,
    Andreas

  3. #3
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    38

    Default

    You should not cache the SessionFactory, because it's a singleton. Use the ContextSingletonBeanFactoryLocator with your applicationContext.xml and all of your SLBs will have access to the same instance of the SessionFactory.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •