达令说
DAO需要继承DAO extends HibernateDaoSupportapplicationContext.xml中需要注入sessionFactory<bean id="adminManagerDAO" class="com.guigu.store.dao.AdminManagerDAO"><!--注入SessionFactory --><property name="sessionFactory" ref="sessionFactory"></property></bean>Session session = getHibernateTemplate().getSessionFactory().openSession();SQLQuery query = session.createSQLQuery("select * from user_kissfly");query.addEntity(UserKissfly.class);query.setFirstResult(0);//query.setFetchSize(3);query.setMaxResults(4);List<UserKissfly> list =query.list();// for(UserKissfly user:list){// System.out.println("当前用户的部门是:" + user.getDeptKissfly().getDeptname());// }System.out.println("查到的数据条数为:" + list.size());session.close();