• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is this right way to Initiaize Hibernate configuration?

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I am designing a web application using Spring+Hibernate web application.

I am injecting these property in each bean I Intialize here is a example of one bean


I am using this hibernatePropertis configuration in many beans in Spring is this right approach to use Hibernate in Spring?

Thanks
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. You should only create one SessionFactory/EntitnyManagerFactory for your entire application. And you "registerEmployeeBean" Is not of type LocalSessionFactoryBean.

In A Spring Application you use a layered approach. Service layer for your business use case code and transaction demarcation at methods level. Repository Layer that stores your queries to run. And then there is the SessionFactory underneath. The sessionFactory gets injected into your repository classes. So one bean for sessionFactory and one bean per repository class with dependency injection injecting the sessionFactory into the repository classes. Then the repository classes are injected into the Service layer classes.

Mark
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Mark

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic