当前位置: 代码迷 >> J2SE >> Association references unmapped class: dboperation.Exceptionrecord
  详细解决方案

Association references unmapped class: dboperation.Exceptionrecord

热度:226   发布时间:2016-04-24 13:12:39.0
求救Hibernate中的HQL EDITOR配置问题
新建一个工程,用Myeclipse生成以后HQL EDITOR可用.

但是在旧工程里生成一个包,然后把表反序列化生成类到包里以后,用这个工程Myeclipse->HQL Editor...
右下角出现Session factory not created for configuration: MyHibernate提示

硬写from tableA就出现
A session factory for this configuration could not be built,dynamic query translation will be unavailable . Queries cannot be executed.

Reason:
Association references unmapped class: dboperation.Exceptionrecord

若是说配置问题,但是我写了测试类:
ExceptionrecordDAO hdao=new ExceptionrecordDAO();
List xxx=hdao.getSession().createQuery("from Exceptiontyperef").list();
for (int i=0;i<xxx.size();i++)
{
Exceptiontyperef er=(Exceptiontyperef)xxx.get(i);
System.out.println(er.getTypeid());
}

却能够正确的读取出数据库里的值,也就是说配置应该没问题

百思不得其解,求助

------解决方案--------------------
但是在旧工程里生成一个包,然后把表反序列化生成类到包里以后,用这个工程Myeclipse->HQL Editor...
右下角出现Session factory not created for configuration: MyHibernate提示

硬写from tableA就出现
A session factory for this configuration could not be built,dynamic query translation will be unavailable . Queries cannot be executed.


发现你在hql里面写的是sql语句,按照常理来说,你在hql编辑里面就应该写hql语句吧。
------解决方案--------------------
我和楼主一样的问题:在Hibernate Dynamic Query Translator 中出现:Session factory not created for configuration: hibernatedemo
public static void main(String[] args)
{
Session session = HibernateSessionFactory.getSession();
Query q = session.createQuery("from BgBlog");
List list = q.list();
for(Object o:list)
{
BgBlog b = (BgBlog)o;
System.out.println(b.getItemid());
}
session.close();
}
取值正确。
唯一的问题就是:在HQL Editor中输入任何内容运行,没有任何反应。没有结果,也没有看到大家说的报错信息。百思不解!
代码迷推荐解决方案:org.hibernate.MappingException: Association references unmapped class,http://www.daimami.com/j2ee/326371.html
  相关解决方案