• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Hibernate SessionFactory is initialized/read with every EJB call

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am working with Spring a couple of weeks now.
We are using Spring framework in a standard J2EE application (Hibernate / EJB / Struts).


I have observed that my Hibernate sessionfactory is repeatedly created/instantiated when my EJBs are accessed (for the first time).
As I have understood from the spring documentation, every EJB has it's own instance of the Spring application context.
My first conclusion is : if I have 7 EJB stateless session beans in my EJB container, I have also 7 initializations of sessionfactory.

That is, 7 times hibernate mapping initialization ...

My question is:
"I would want to have only one instance (=one initialization) of sessionfactory which is global for all EJBs AND I do NOT want to use JNDI registration of my Hibernate sessionfactory as MBean(JMX) (Hibernate in Action).?"

Mind you: we are using an older version of BEA Weblogic which has possible no support for JMX / MBeans.


Ideas? Because I am kind of dazzled about the way Spring contexts are implemented with respect to the scope of spring beans.

ThanX
Urso Wieske
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use singleton pattern for that
 
You get good luck from rubbing the belly of a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic