org.hibernate.HibernateException:无法确定动态实体的类型

时间:2019-04-09 11:00:21

标签: java hibernate

我是Hibernate的初学者,在我的一个项目中有以下代码:

ShortHand o = new ShortHand();
    Session sess = noprobs.getSessionFactory().openSession();


                    sess.getTransaction().setTimeout(noprobs.xActionTimeout);
                tx = sess.beginTransaction();
                sess.save(o);

我收到以下错误:

错误:

org.hibernate.HibernateException: could not determine type of dynamic entity
    at org.hibernate.impl.SessionImpl.guessEntityName(SessionImpl.java:1770)
    at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
    at cool.wxhy.tms.xyz.ABCD.persistInDb(ABCD.java:235)
    at cool.wxhy.tms.xyz.ABCD.subscribeToAmps(ABCD.java:144)
    at cool.wxhy.tms.xyz.ABCD.hot(ABCD.java:102)
    at cool.wxhy.service.impl.wxhyBase.start(wxhyBase.java:250)
    at cool.wxhy.service.api.hello.startAllServices(hello.java:211)
    at cool.wxhy.service.impl.heyhi.main(heyhi.java:43)

我正在使用HIbernate 3.2.6 jar

我正在为HIbernate使用xml配置,而不是注释之一。有人可以帮忙解决这个问题。

休眠映射文件:

<hibernate-mapping package="bofa.pioneer.tms.objects">
    <class name="ShortHand" table="ShortHand">
      <id name="key" column="id" unsaved-value="null" type="string" >
        <generator class="assigned" />
      </id>

        <property name="animal" column="animal" type="string"/>
        <property name="dog" column="dog" type="string"/>

实体

public class ShortHand extends LongHand {
 //getters and setters are present in the parent LongHand
 }

0 个答案:

没有答案