单独使用Hibernate3.3时,由myeclipse自动生成注解式配置,在测试时发生如下错误:
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1648)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
at com.dbUtil.HibernateSessionFactory.(HibernateSessionFactory.java:31)
at com.dao.BaseHibernateDAO.getSession(BaseHibernateDAO.java:16)
at com.dao.ProductDAO.findAll(ProductDAO.java:140)
at com.service.impl.ProductServiceImpl.queryAll(ProductServiceImpl.java:26)
at test.ImplTest.test1(ImplTest.java:18)
…
原因是由于:在HibernateSessionFactory里边的:private static Configuration configuration = new Configuration();
只要改为:private static Configuration configuration = new AnnotationConfiguration();就编译通过了
org.hibernate.MappingException: An AnnotationConfiguration
最新推荐文章于 2021-10-06 12:05:17 发布