Spring + Hibernate

xiaoxiao2021-03-04  53

Spring Hibernate Select BLOG in Carlhui these days to compare empty, just learn Spring and Hibernate (introduced in this regard in Spring in Spring). The following main introduction has used Hibernate to change 1, used Hibernate in the configuration file for an increase sessionFactory configuration, the following net / zdsoft / SWH / Entity / Company.hbm.xml net.sf.hibernate.diaforct. MySQLDIALECT net.sf.hibernate.cache.oscacheProvider true true true 2, using transaction management below < Bean id = "transactionManager" class = "org.springframework.orm.hibernate.hibernateTransactionManager">

. 3, the original DAO inherited JDBCDaoSupport HibernateDaoSupport longer to increase DAO sessionFactory implantation in the configuration file, the following public class CompanyDAOHibernate extends HibernateDaoSupport implements CompanyDAO {public Company findById (String id) throws HibernateException {Company c = (Company) getHibernateTemplate ( ) .load (Company.class, id); return c;} public Company addCompany (Company company) throws HibernateException {getHibernateTemplate () save (company);. return company;} public void removeCompany (Company company) throws HibernateException {getHibernateTemplate ( ) .delete (company);} public Company updateCompany (Company company) throws HibernateException {getHibernateTemplate () saveOrUpdate (company);. return company;}} " sessionFactory "/> Other basic invariant author blog:

http://blog.9cbs.net/carlhui/

转载请注明原文地址:https://www.9cbs.com/read-31657.html

New Post(0)