Announcement Announcement Module
Collapse
No announcement yet.
Spring Hibernate Integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Hibernate Integration

    I have implemented a spring mvc application integrated with Hibernate, in two ways:
    1. I have created one hibernate.cfg.xml and NewHibernateUtil.java (to return me an object of sessionFactory). In my service class i always create a session object by invoking:

    Session currentSession = NewHibernateUtil.getSessionFactory().openSession() ;

    2. The same thing can be done by integrating hibernate configuration in the dispatcher-servlet like..
    <bean id="dataSource"...

    <bean id="sessionFactory" ....

    and reference injecting the object of sessionFactory in my respective service class.

    Which one is the best way in terms of performance and code-optimization?

  • #2
    1. Isn't integrating with spring and requires manual ssession and transaction management
    2. Is the proper way.

    Comment


    • #3
      Thanks for your response..

      Comment


      • #4
        I think point 2 is the right approach.

        Comment


        • #5
          thank you for the info!

          Comment

          Working...
          X