我在Spring中遇到sessionFactory的問題。「屬性」sessionFactory'是必需的「在春季?
public abstract class GenericDao<T,PK extends Serializable>
extends HibernateDaoSupport
implements IGenericDao<T, Serializable> {
private Class<T> persistentClass;
public Class<T> getPersistentClass() {
return persistentClass;
}
public void setPersistentClass(Class<T> persistentClass) {
this.persistentClass = persistentClass;
}
@Repository
@Transactional
public class CategoryDao extends GenericDao<Category, Long> {
@Autowired
private SessionFactory sessionFactory;
public CategoryDao() {
setPersistentClass(Category.class);
setSessionFactory(sessionFactory);
}
而且在appContext.xml文件中定義我的sessionFactoryBean。
我做了你的建議:) –