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

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
 
I didn't say it. I'm just telling you what this tiny ad said.
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