Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

CHAPTER 9: Using Hibernate in Spring > The Hibernate Session Interface

The Hibernate Session Interface

In Hibernate, when interacting with the database, the major interface you need to deal with is the Session interface, which is obtained from the SessionFactory.

Listing 9-12 shows that the ContactDaoImpl class contains the samples in this chapter. The configured Hibernate SessionFactory was injected into the class.

Listing 9-12. Injecting Hibernate SessionFactory

package com.apress.prospring3.ch9.dao.hibernate;

// Import statements omitted
@Repository("contactDao")
@Transactional
public class ContactDaoImpl implements ContactDao {

    // Other code omitted
    private Log log = LogFactory.getLog(ContactDaoImpl.class);

    private SessionFactory sessionFactory;

    public SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    @Resource(name="sessionFactory")
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint